Re: Recursive file remove
Re: Recursive file remove
- Subject: Re: Recursive file remove
- From: Michael Ash <email@hidden>
- Date: Sun, 15 Aug 2010 00:36:02 -0400
On Sat, Aug 14, 2010 at 7:31 PM, Kyle Sluder <email@hidden> wrote:
> On Sat, Aug 14, 2010 at 11:46 AM, Michael Ash <email@hidden> wrote:
>> Er, as far as I can tell from a quick look at the docs, every
>> NSFileManager remove... method is documented to be recursive and there
>> isn't any way to turn that *off*....
>
> Pardon me if I'm being dense, but what would a "non-recursive delete"
> even mean? If you delete the directory, it's gone, as its entire
> subtree.
I could see two reasonable meanings.
First is the more obvious one, where you have the semantics of doing
an 'rm' on a directory without passing the -r flag. If the directory
is empty, it's deleted. If it's not, the command fails.
Second would be something that removes the directory from its
enclosing directory but does *not* remove the contents from the
directory. Why would you ever do such a thing? Imagine a directory
with multiple hard links, as used in Time Machine. If you do a
standard recursive delete on one of those hard links, you'll remove
the link *and everything inside*. The remaining links still exist, but
are now empty. Whoops. Simply removing the directory without removing
the contents will delete that particular hard link and leave the rest
intact. (Incidentally, this is why you should probably NOT go poking
around and figuring out how to bypass the access protections on your
TM volume so you can delete entire trees with 'rm' instead of the
GUI.)
This second interpretation could be dangerous if you use it on the
only entry for a directory, and you end up orphaning a bunch of data.
If your filesystem isn't smart enough to clean that stuff up, you'll
end up with a bunch of files that can't be accessed or deleted....
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden