You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JimfsPath.resolve(Path) doesn't accept Path instance if it's not a JimfsPath one, even if the given Path is a relative one.
When the given Path is not absoute why not to convert to string and parse if to create a JimfsPath ?
something like this
public JimfsPath resolve(Path other) {
if(!other.isAbsolute()) {
// Convert other in a JimfsPath using String representation
other = pathService.parsePath(other.toString());
}
// Start of existing code
JimfsPath otherPath = checkPath(other);
if (otherPath == null) {
throw new ProviderMismatchException(other.toString());
}
...
}
My use case is
public void productionCode(Path rootPath) {
...
Path relPath = Paths.get("xxx", "yyy", "zzz");
...
Path fullPath = rootPath.resolve(relPath);
...
}
@Test
public void test() {
// Given
FileSystem fileSystem = Jimfs.newFileSystem();
Path rootPath = fileSystem.getPath("input").toAbsolutePath();
// When
productionCode(rootPath);
}
I see discussion on #12, i understand the limitation of JimfsPath.resolve(Path) for absolute path, but resolving relative path can be done (IMO)
using toString() and parsePath
using Path.iterator() to retrive all part of the path
The text was updated successfully, but these errors were encountered:
In addition to what Jake said about the behavior being consistent with the Java-provided filesystems:
I would argue that your code is incorrect usage of the APIs (the Path relPath = Paths.get("xxx", "yyy", "zzz"); line specifically); since your productionCode method accepts a Path, the correct way to create a Path that you intend to use with rootPath would be rootPath.getFileSystem().getPath("xxx", "yyy", "zzz"). If you do that, there's no file system mismatch issue.
It doesn't make sense in general to try to resolve a Path from one file system against a Path from another given that file systems may have differing semantics. For example, what would you expect to happen if you attempt to resolve UNIX-like Path "foo\bar\baz" (a single filename) against a Windows file system? Different people or different situations might expect different things to happen, and it doesn't really make sense for each file system implementation to have to attempt to deal with any possible implementation of Path it might be given. This is more just my opinion on why the existing file systems don't attempt to deal with this and why we don't want to either.
JimfsPath.resolve(Path)
doesn't accept Path instance if it's not a JimfsPath one, even if the given Path is a relative one.When the given Path is not absoute why not to convert to string and parse if to create a JimfsPath ?
something like this
My use case is
I see discussion on #12, i understand the limitation of
JimfsPath.resolve(Path)
for absolute path, but resolving relative path can be done (IMO)The text was updated successfully, but these errors were encountered: