Wrong exception thrown?
mthornton at optrak.co.uk
Tue Sep 1 06:42:06 PDT 2009
Alan Bateman wrote:
> 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
>> to it. I must specify ATOMIC_MOVE to prevent it actually moving any
>> only a rename is desired.
>> Would it be better to instead check if srcPath and dstPath are on the
>> 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.
Surely that is also subject to potential races --- another process could
change the FileStore associated with a path.
More information about the nio-dev