marschall / memoryfilesystem

An in memory implementation of a JSR-203 file system
282 stars 36 forks source link

Unable to determine if root directory exists #125

Closed phermsdorf closed 3 years ago

phermsdorf commented 3 years ago

Hi,

i tried using your library, but got stuck in a unit test. When trying to create a folder on a different windows disc than c: i get the following error

java.nio.file.FileSystemException: D:\otherfolder\child1: Unable to determine if root directory exists
    at java.nio.file.Files.createDirectories(Files.java:756)

I found in you testcases only one example where you are not using C: but D: but in this cases no folder get's created.

My example:

FileSystem fileSystem = MemoryFileSystemBuilder.newWindows().build();
//working
Files.createDirectories(fileSystem.getPath("C:\\folder\\child1"));
//not working
Files.createDirectories(fileSystem.getPath("D:\\otherfolder\\child1"));

Any idea what the problem could be? Would be great if that could be supported since i need to implement a test for a copy operation from one windows device to the other ...

Thanks.

Bye Peter

marschall commented 3 years ago

I'll have a look in the following days. In the mean time, if you want to be able to use a D: drive can you try the following

MemoryFileSystemBuilder.newWindows().addRoot("D:\\").build();

Per default only a C: drive is added.

phermsdorf commented 3 years ago

Great, that works fro me!

Thanks a lot!

Bye, Peter

marschall commented 3 years ago

The exception is thrown by java.nio.file.Files#createDirectories(Path, FileAttribute<?>...) because provider(parent).checkAccess(parent) throws NoSuchFileException for D:. I believe this is correct because it does not exists.

7ef1805aa1785080be71a1f778851174a0975d52 improves the documentation and adds a regression test.