PDA

View Full Version : CocoaTechFoundation source/getting "correct" file-


defusion
Jun 26, 2005, 10:47 PM
I'm trying to build a simple finder (for use as a file-browser within a text-editor I am building) and am attempting to get a "correct" list of files - ala Finder (and of course, PathFinder).

I've browsed thru your source, and the cocoa support lists and it seems like the following is how I should deal with a directory list of files:

* ignore any files in /.hidden (this is not-used anymore in Tiger)
* ignore any files beginning with "."
* ignore any files with their hidden bit set
* cater for some special files (such as "/Volumes").

I've got the 1st two parts working (and the last part is trivial), and have looked at your source for the 3rd part.

to summarize, you do something like the following to check the "hidden" bit:

- (BOOL)isInvisible:(NSString *)path;
{
FSRef fsRef;
FSCatalogInfo catalogInfo;

OSStatus err;
FSPathMakeRef((const UInt8*)[path fileSystemRepresentation], &fsRef, NULL);
err = FSGetCatalogInfo(&fsRef, kFSCatInfoGettableInfo, &catalogInfo, NULL, NULL, NULL);

return ((((FileInfo*)catalogInfo.finderInfo)->finderFlags & kIsInvisible) != 0);
}


However, if I run this on my root ("/") this does not return correctly for:

/etc (a symlink to private/etc)
/mach (a symlink to /mach.sym)
/mach.sym (a file - this is the problem)
/tmp (a sym link to private/tmp)
/var (a sym link to private/var)

4 out of the 5 of the above are symbolic-links to files that are hidden, so I assume that is how you decide whether to show or not - however there is 1 file - "/mach.sym" - which appears to be an ordinary file (i.e. not a dir, or symlink). Any ideas how I deal with this file?

Many thx.

D.