You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "chenshuming (Jira)" <ji...@apache.org> on 2020/06/13 01:35:00 UTC

[jira] [Commented] (VFS-226) resolving of relative layers does not work correctly

    [ https://issues.apache.org/jira/browse/VFS-226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17134616#comment-17134616 ] 

chenshuming commented on VFS-226:
---------------------------------

Maybe you can try this :

```

public void test() throws IOException {
    FileSystemManager manager = VFS.getManager();

    try (FileObject f1 = manager.resolveFile(new File("src/test/resources/test-data").getAbsolutePath());
            FileObject f2 = f1.resolveFile("test.zip");
            FileObject f3 = manager.createFileSystem("zip",f2);
    ) {
          System.out.println(f3.getName());
   }
}

```

I think the FileObject.resolveFile(String) method don't accept scheme in parameter.

In this case, I think  we can call FileSystemManager.create(String, FileObject) if we want to open a zip file use "zip" scheme.

> resolving of relative layers does not work correctly
> ----------------------------------------------------
>
>                 Key: VFS-226
>                 URL: https://issues.apache.org/jira/browse/VFS-226
>             Project: Commons VFS
>          Issue Type: Bug
>         Environment: Windows XP, Java 1.4
>            Reporter: Frank van der Kleij
>            Priority: Major
>
> When I try to resolve a relative layered filesystem I get the error 
> Could not find file with URI "rules.zip" because it is a relative path, and no base URI was provided.
> I used the method StandardFileSystemManager.resolveFile(FileObject, String) where the FileObject is the directory where the file rules.zip is located (file:///d:/temp) and for the path I use 'zip:rules.zip'.
> Since I pass a base file I would think it should be able to find the zip file.
> When debugging I found the following:
> LayeredFileNameParser.parseUri(VfsComponentContext, FileName, String) does one line 54:
> rootUri = context.parseURI(rootUriName);
> I believe that in this call it loses the reference to the base file I passed .
> The context forwards to the FileSystemManager.resolveURI(String)
> which throws the exception because its base file isn't set:
> if (baseFile == null)
> {
> 	throw new FileSystemException("vfs.impl/find-rel-file.error", uri);
> }



--
This message was sent by Atlassian Jira
(v8.3.4#803005)