Which one is correct mv or Path#move?
Alan Bateman
Alan.Bateman at Sun.COM
Thu Jul 31 04:33:44 PDT 2008
Rajendra Gutupalli wrote:
> Hi Alan,
>
> I see difference in behavior between command mv and Path.move(). I
> created and moved a hardlink to a assigned drive (using subst command )
> for a directory in C:\.
> After moving using mv the link count for the file to which hard link is
> created is reduced but after moving Path.move I don't see any reduction
> in link count.
Is this Cygwin or MKS "mv"? I'll bet it is copying the file in this
scenario and this will explain your observations. That is, it may
"think" it is being asked to move a file to another volume whereas in
fact the target maps to the same volume. One way to check if the file
has been copied is to use the isSameFile method.
> Please see the following result in command line and using program.
>
> But if I assign a drive for a network folder in C drive using net
> command ( net use M \\rajendra\temp : where temp is in C drive)and move
> the hard link to this drive I see link count is reduced in both cases
> (ie. using mv and Path.move).
In this scenario you are moving a file to another volume so it will
always require copying it (and deleting the original which will result
in the link count being decremented).
-Alan.
More information about the nio-dev
mailing list