Re: Renaming and moving files
Re: Renaming and moving files
- Subject: Re: Renaming and moving files
- From: Andy Lee <email@hidden>
- Date: Fri, 8 Mar 2002 22:13:29 -0500
At 5:21 PM -0600 3/8/02, Charles Srstka wrote:
>
On Friday, March 8, 2002, at 09:33 AM, Lance Bland wrote:
>
>Here is what I did:
>
>went to the Apache htdocs directory (I don't have permission to write there).
>
>Opened up a .html file by dragging it to TextEdit icon in the dock.
>
>added a space (so the document needed saving)
>
>clicked apple-s
>
>it said I don't have permission to overwrite, but I say do it anyways.
>
>Then it says I can't.
>
>
>
>and here is what the result is:
>
>
>
>-rw-r--r-- 1 lbland admin 5248 Mar 8 10:28 2621-37294084-1.html
>
>-rw-r--r-- 1 root admin 5248 Jan 21 09:11 index~.html
>
>
>
>there use to be only one file there with the name "index.html".
I've only been skimming this thread, but I think I see what is going on, at least with this TextEdit example.
When TextEdit saves a file, it first renames the original file with a "~" added to the name. In this case, "index.html" became "index~.html". Since you did not have write permission on the file, you got the first message from TextEdit. But TextEdit allowed you to override the file's permissions (perhaps because it knows you're an admin user?), so it went ahead and renamed the file.
At this point the directory contained "index~.html" and no file named "index.html". TextEdit proceeded to save your new, edited file contents to "index.html", which you *did* have permissions to do (to add a file to a directory, what you need is write permissions on the *directory*). Now you have the two files you listed above, both "index.html" and "index~.html". The ownerships, permissions, and dates on the files make sense.
TextEdit has a preferences option to "Delete backup file", meaning the "~" file. By default this is turned on, so now TextEdit wanted to delete "index~.html". But it couldn't, because you don't don't own that file. This caused the second message. Mystery explained.
This thread began with Andreas's question, "Is there any way in Cocoa to rename files? Or move them in a logical manner?" TextEdit's error reporting could have been clearer, but this particular example does not reflect shortcomings that may or may not be in low-level Cocoa functions.
I do find Andreas's initial anecdote -- about the Applications directory getting trashed -- a little scary. I haven't tried figure that one out.
--Andy
_______________________________________________
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.