-
-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Description
A lot of methods are wrong. Here is some sample test code that compares the PathFS with a standard JarFS:
FileSystem jarFs = FileSystems.newFileSystem(URI.create("jar:file:/path/to/JarJar/src/binks/resources/dir1.zip"), new HashMap<>());
FileSystem pathFs = FileSystems.newFileSystem(URI.create("path:///test"), ImmutableMap.of("packagePath", Paths.get("/path/to/JarJar/src/binks/resources/dir1.zip")));
System.out.println("normalize + absolute: jarfs: " + jarFs.getPath("/abc/../../def").normalize().isAbsolute());
System.out.println("normalize + absolute: pathfs: " + pathFs.getPath("/abc/../../def").normalize().isAbsolute());
System.out.println("relativize: jarfs: " + jarFs.getPath("/abc/xyz").relativize(jarFs.getPath("/abc/def/ghi")));
System.out.println("relativize: pathfs: " + pathFs.getPath("/abc/xyz").relativize(pathFs.getPath("/abc/def/ghi")));
System.out.println("name count: jarfs: " + jarFs.getPath("/abc/xyz").getNameCount());
System.out.println("name count: pathfs: " + pathFs.getPath("/abc/xyz").getNameCount());
System.out.println("root: jarfs: " + jarFs.getPath("abc/xyz").getRoot());
System.out.println("root: pathfs: " + pathFs.getPath("abc/xyz").getRoot());
System.out.println("parent: jarfs: " + jarFs.getPath("").getParent());
System.out.println("parent: pathfs: " + pathFs.getPath("").getParent());This gives
normalize + absolute: jarfs: true
normalize + absolute: pathfs: false
relativize: jarfs: ../def/ghi
relativize: pathfs: ../abc/def/ghi
name count: jarfs: 2
name count: pathfs: 3
root: jarfs: null
root: pathfs: /
parent: jarfs: null
parent: pathfs:
As you can see, some outputs are completely wrong. Like an absolute path should not get relative when normalizing.
Currently JarJar faces similar problems as securejarhandler did. My proposed solution to the problem is to copy the path implementation from McModLauncher/securejarhandler#26 into JarJar as it has extensive tests against a JarFS and (to my knowledge) fulfills the Path spec.
Metadata
Metadata
Assignees
Labels
No labels