Re: The invisible file in Macintosh?
Re: The invisible file in Macintosh?
- Subject: Re: The invisible file in Macintosh?
- From: "John C. Daub" <email@hidden>
- Date: Fri, 17 Sep 2004 07:46:50 -0500
on 9/17/04 12:44 AM, wall at email@hidden wrote:
> When I open the sysytem volume with Finder, I can only
> see Developer, Applications, System, Users,
> Library......
> But when use "ls" to see the "/", I can see dev, etc,
> mach, sbin, usr and other files or folders.
> How can I distinguish between the two kind of files,
> and show the files like in the Finder ?
> Thanks .
The Finder (and things like Open/Save/Choose dialogs) generally work to hide
invisible items from the user. So what you need to do is determine if the
item is invisible or not. If it's invisible, then don't show it (that's what
the Finder does).
There are numerous ways to determine if an item is invisible.
- the kIsInvisible Finder flag is set (see Carbon's Finder.h)
- the filename begins with a period, e.g. ".foo". This is an old Unix
standby.
- If the item is within an item that's invisible. So if you have:
folder1
folder2
folder3
file1
Then file1 is considered invisible (at least as far as showing it in the
Finder is concerned) if any of those parent folders are invisible. So if
folder1 is invisible, then file1 is invisible too... since if you can't see
folder1, there's no way you could navigate down to and thus see file1.
- If the item is listed in the /.hidden file, or again through parentage.
The ".hidden" file is a bit of a hack that I think Apple is doing their best
to do away with (maybe in Tiger it's finally gone... I'm not sure). But it's
a file that resides at the top level of any volume (I believe any volume),
and is simply a list of files and folders also at the top level that are to
be special-cased for an considered invisible. So anything listed in there
that's also at the root level of the volume should be treated as invisible.
And then given the previous rule about "items within invisible items are
invisible", same applies here. So "etc" is listed as invisible in the
.hidden file, thus anything with /etc is invisible.
- If an item is within a package (a package, not a bundle... i.e. a folder
that the Finder treats as a file), then you could also consider that to be
invisible since the contents of a package are generally not displayed in the
Finder. You can determine if an item is a package or not by using Launch
Services (Carbon), and I believe NSWorkspace isFilePackageAtPath: works for
Cocoa.
-------
These are basically the ways to consider an item "invisible". Just which
ways apply to your situation you have to determine.
--
John C. Daub }:-)>=
<mailto:email@hidden> <http://www.hsoi.com/>
"Virtue does not come from money, but rather from virtue
comes money, and all other things good to man." - Socrates
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden