Re: File system visiblilty
Re: File system visiblilty
- Subject: Re: File system visiblilty
- From: Rob Keniger <email@hidden>
- Date: Thu, 15 Nov 2007 12:53:01 +1000
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:
This email sent to email@hidden