Re: Instantly delete a directory without recursion?
Re: Instantly delete a directory without recursion?
- Subject: Re: Instantly delete a directory without recursion?
- From: Oleg Krupnov <email@hidden>
- Date: Mon, 4 Oct 2010 16:21:37 +0300
Thanks everyone! Now I see.
Oleg.
On Mon, Oct 4, 2010 at 4:14 PM, Kirk Kerekes <email@hidden> wrote:
>> Is there a way to delete a directory instantly and completely without
>> first deleting all its subdirectories and files recursively?
>
> The hierarchical structure that you see is not "real" -- directories are not physical containers for the files that they appear to contain. The directory hierarchy is a carefully maintained fiction.
>
> Irrelevant aside:
> The original Mac file system took this a step further -- it made the directory structure
> totally a visual fiction -- all of the files were at the root of the (3.5") floppy)
> disk, and only _seemed_ to be arranged in folders. Thankfully this was supplanted by HFS.
>
> It is better to think of directories/folders as a special kind of file that contains an index to a set of files that it is going to _pretend_ to contain.
>
> Conceptually, this works much like classical Cocoa memory management. Each (directory/object) "owns" a set of (files/objects) by reference ("retains" the (file/object)).
>
> When you delete a file from a directory, it is "released". If no other directory has an ownership claim on that file, it is "dealloc'ed".
>
> Your (folder/object) doesn't contain the objects that it "owns". It doesn't really even "own" them -- it just has a "ownership claim" on them.
>
> From Wikipedia's article about Hard Links:
>
>> "a hard link is a directory entry that associates a name with a file on a file system. A directory is itself a special kind of file that contains a list of such entries."
>
> Note that due to the use of hard links it is possible to have a single physical file that can appear in multiple directories. Each one of those directories owns a reference to the "real" file. Each reference is as "real" as any other. All references have to be "unlinked" for the file to be marked as deleted.
>
> The "file" can even have different "names" in the different directories!
>
> Hard links are the chain saw of filesystem features -- powerful, but potentially quite dangerous. Note that the OSX GUI provides no means of producing hard links, or even symlinks.
>
>
>
>
_______________________________________________
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