Wrong exception thrown?
Alan.Bateman at Sun.COM
Tue Sep 1 06:30:40 PDT 2009
John Hendrikx wrote:
> Yes, correct it was a directory.
> I didn't however specify REPLACE_EXISTING, only ATOMIC_MOVE (and the
> latter is documented to "ignore all other options").
> I'm actually only trying to accomplish a simple rename of the directory --
> but I couldn't find any other function that accomplishes this in nio2, so
> I suspected that srcPath.moveTo(dstPath, ATOMIC_MOVE) is the closest thing
> to it. I must specify ATOMIC_MOVE to prevent it actually moving any data,
> only a rename is desired.
> Would it be better to instead check if srcPath and dstPath are on the same
> FileStore and only then call srcPath.moveTo(dstPath) without any further
It's good to bring this up as the assumption has been most applications
will use source.moveTo(target) or source.moveTo(target,
REPLACE_EXISTING) and not care if the target is on a different
volume/file-system. The right thing is probably to introduce something
like a NOCOPY_ALLOWED or some such option. For you, you are correct,
that you can check if the source and target FileStore are equal.
More information about the nio-dev