Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File system visiblilty




On 15/11/2007, at 10:52 AM, Justin Hawkwood wrote:

I use the following methods to get the visibility of files in the file system, but still some file some up in my list that do not show up in the Finder. Any suggestions to get results more like the Finder gives?


You're using LaunchServices which is the right way to do this, however you are not creating the FSRef properly. John is right, you shouldn't use NSASCIIStringEncoding as paths are definitely not ASCII. I use CFURLGetFSRef to create the FSRef which is much simpler.

You also don't need to check for the period at the beginning of the file name etc because the Launch Services check does all that for you.

I use code similar to this:

-(BOOL)isVisible:(NSString *)path
{
//check to see if the file is visible by inspecting the LaunchServices attributes
FSRef ref;
if (CFURLGetFSRef((CFURLRef)[NSURL fileURLWithPath:path],&ref))
{
CFTypeRef isInvisible;
if(LSCopyItemAttribute(&ref, kLSRolesAll, kLSItemIsInvisible, & isInvisible)==noErr)
{
if(isInvisible!=kCFBooleanTrue)
{
[visibleFolderContents addObject:currentFileName];
}
CFRelease(isInvisible);
}
}
}



-- Rob Keniger _______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >File system visiblilty (From: Justin Hawkwood <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.