Skip navigation.
 
mlRe: Changing file & directory names
FROM : Derrick Bass
DATE : Sun Jul 02 02:28:11 2006

On Jul 1, 2006, at 4:10 PM, Sherm Pendley wrote:

> Belief is unnecessary - just test it. Dump a huge file on your disk 
> somewhere, then use -movePath:toPath:handler: to move it. For a 
> large enough file (a CD or DVD image, for instance), it would be 
> immediately apparent which is the case - if the file's contents 
> were being copied, there would be a noticeable delay.


I was so astonished by this thread that I did, indeed test it. I 
don't think I ever even bothered to read the documentation on 
movePath:toPath:handler: because it never occurred to me that it 
would not work just the UNIX mv command: if the source and 
destination are on the same volume, then the file/directory is simply 
moved, otherwise it is copied. By moved I mean the directory entry is 
removed from the source directory and placed into the destination 
directory (which, by the way, has nothing to do with link (2) and 
unlink (2) but rather with rename (2)).

This is, in fact, what happens.

Also, I'm but confused by Sherm Pendley's mention of link and unlink. 
I think he's assuming it is correct but needs a tortured 
interpretation in order to reconcile it with our notion of what 
should happen. Anyway, he's right that no copies are made. But also, 
no hard links are made, either. As someone else pointed out, it is 
actually possible on HFS+ to detect whether or not a file has ever 
had multiple links. Once it is multiply linked, it acts forever 
differently, even if all but one of those links is subsequently 
deleted. The easiest way to see the difference is with hfsdebug.
<http://www.osxbook.com/software/hfsdebug/>

(I suppose one could also do a test like Sherm's by making a 
directory with a huge number of files; if hard links were being made 
to all those files, it would take a noticeable amount of time; I did 
not try this.)

The documentation is simply incorrect. I suspect that all that stuff 
about copying the file and then deleting the original, or doing a 
recursive copy for a directory was supposed to be preceded by words 
like "If the the source and destination are not on the same volume" 
and those words somehow never made it in.

Anyway, for the OP, go ahead and use movePath:toPath:handler:. And 
file a bug report on the documentation.

Derrick

Related mailsAuthorDate
mlChanging file & directory names Dean Snyder Jul 1, 19:23
mlRe: Changing file & directory names Greg Titus Jul 1, 19:26
mlRe: Changing file & directory names Dean Snyder Jul 1, 19:41
mlRe: Changing file & directory names Sherm Pendley Jul 1, 20:15
mlRe: Changing file & directory names John Stiles Jul 1, 21:18
mlRe: Changing file & directory names Dean Snyder Jul 1, 21:28
mlRe: Changing file & directory names John Stiles Jul 1, 21:40
mlRe: Changing file & directory names Sherm Pendley Jul 1, 21:41
mlRe: Changing file & directory names Sherm Pendley Jul 1, 21:47
mlRe: Changing file & directory names Dean Snyder Jul 1, 21:57
mlRe: Changing file & directory names John Stiles Jul 1, 22:13
mlRe: Changing file & directory names Sherm Pendley Jul 1, 23:10
mlRe: Changing file & directory names Sherm Pendley Jul 1, 23:19
mlRe: Changing file & directory names Rosyna Jul 2, 02:26
mlRe: Changing file & directory names Derrick Bass Jul 2, 02:28
mlRe: Changing file & directory names Sherm Pendley Jul 2, 03:21
mlRe: Changing file & directory names Dean Snyder Jul 2, 03:39
mlRe: Changing file & directory names Chris Suter Jul 2, 03:47
mlRe: Changing file & directory names Dean Snyder Jul 2, 03:54
mlRe: Changing file & directory names Adam R. Maxwell Jul 2, 09:16
mlRe: Changing file & directory names Matt Neuburg Jul 2, 09:27
mlRe: Changing file & directory names Frode Jul 2, 11:17
mlRe: Changing file & directory names John Stiles Jul 2, 18:20
mlRe: Changing file & directory names Sean McBride Jul 4, 18:07
mlRe: Changing file & directory names Adam R. Maxwell Jul 4, 18:41
mlRe: Changing file & directory names Andy Lee Jul 5, 03:11