Re: Um... How do you rename a file?
Re: Um... How do you rename a file?
- Subject: Re: Um... How do you rename a file?
- From: Alastair Houghton <email@hidden>
- Date: Thu, 25 Mar 2004 12:29:11 +0000
On 25 Mar 2004, at 11:47, Ken Tozier wrote:
>
I'll try that, thanks.
>
>
> I don't understand why you rule out movePath:toPath? It seem to me
>
> that it is the equivalent of a "mv" shell command, which is a rename
>
> operation, as well as a move operation. Isn't it obvious that
>
> "destination must not yet exist", if you're going to rename a file?
>
>
I'm not a unix guy, so, to me, move (or mv) means physically transfer a
>
file to a completely different location.
>
>
The documentation states two things which seem in clear conflict (or at
>
least extremely wasteful) as I read it
>
>
1. "the method CREATES a file at destination that holds the exact
>
contents of the original file and then DELETES the original file"
Yes, that is notionally how it works. This doesn't conflict in any way
with the idea of a rename, and the idea that it must be doing this by
copying all of the data is something that you are reading into it... it
certainly doesn't say that. (It only needs to copy if it's moving
across filesystems or on a filesystem without hard links and with no
special support for rename.)
>
2. The file specified in source must exist, while destination must not
>
yet exist.
I don't see how that conflicts either. If I have two files, "foo" and
"bar" in a directory, I shouldn't be allowed to rename "foo" to "bar"
because "bar" already exists. Seems to make sense to me.
>
This says to me that the system creates a new file at destination and
>
copies the entire contents no matter how many tens or hundreds of
>
megabytes it might be, then deletes the original. I'm sure it's not,
>
but that how it reads. Contrast that with:
>
>
[aFile setName:@"jim bob"]
>
>
Done. Much easier and much more intuitive than moving a file you're not
>
really moving.
I take your point about the fact that you aren't really moving the file
so you don't expect to have to use a method called "move". But I'm
sure you can see that renaming a file is just a special case of the
move operation in which you don't change the directory that it's in ---
i.e. there's no need for a separate rename operation.
Kind regards,
Alastair.
--
http://www.alastairs-place.net
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.