google / google/jimfs

Deprecate newFileSystem(...) overloads that default to platform-specific settings

Open
#106 11 comments 0 reactions 0 assignees View on GitHub
P3 type=defect
Dominant language
Java
Stars
2.6k
Forks
296
Avg merge
9m
Merged PRs (30d)
7

Description

The following code

```
try (FileSystem memFs = Jimfs.newFileSystem()) {
Path memFsRoot = memFs.getPath("");
URI uri = memFsRoot.toUri();
Path path = Paths.get(uri);
System.out.println("memFsRoot: " + memFsRoot);
System.out.println("uri: " + uri);
System.out.println("path: " + path);
}
```

prints, on Windows:

```
memFsRoot:
uri: jimfs://4dbef289-e533-4340-8531-fe2cc6b2f0f3/C:/work/
path: C:\work
```

This seems like a bug (even though the `Path` object is linked to the `FileSystem` instance). The path should not need the `C:` drive designation, as far as I can tell, because the GUID in the URI should be sufficient to locate the filesystem. The weird Jimfs `URI` and `Path` syntax makes porting code between Linux and Windows problematic.

On Linux the output is:

```
memFsRoot:
uri: jimfs://4dbef289-e533-4340-8531-fe2cc6b2f0f3/work/
path: /work
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.