marschall / memoryfilesystem

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

move a directory into itself should throw #25

Closed ghost closed 10 years ago

ghost commented 10 years ago

see: https://github.com/openCage/niotest/blob/16ee86ed6d855ea129799c3185464b011049fe26/src/main/java/org/opencage/lindwurm/niotest/tests/PathTest4CopyIT.java testMoveIntoItself

marschall commented 10 years ago

No, it should not. Files.move(java.nio.file.Path, java.nio.file.Path, java.nio.file.CopyOption...)

By default, this method attempts to move the file to the target file, failing if the target file exists except if the source and target are the same file, in which case this method has no effect. …

And neither does the default file system provider. The following code does not throw an exception

Path path = Paths.get("/home/user/temp/afolder");
Files.move(path, path);
ghost commented 10 years ago

sorry bad title. Better would be: moving a dir to a subdirectory of itself should throw, e.g.

Path path = filesystem.getPath("/home/user/temp/afolder");
Path sub = path.resolve( "a-kid");
Files.move(path, sub);  // should throw