Wrong exception thrown?
Mark Thornton
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
>> 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
>> arguments?
>>
> 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.
Mark Thornton
More information about the nio-dev
mailing list