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



First of all, filenames are not ASCII. They use fileSystemRepresentation.
Second, what files in specific are you seeing which you shouldn't? And is "err" ever coming back as anything other than noErr? If so, what did you get?



On Nov 14, 2007, at 4:52 PM, 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?



...
NSMutableArray *pathCont = [NSMutableArray arrayWithArray:[fileMan contentsOfDirectoryAtPath:path error:&fmErr]];
if ([pathCont containsObject:@".hidden"]) {
NSArray *hiddenList = [[NSString stringWithContentsOfFile: [path
stringByAppendingPathComponent:@".hidden"]]
componentsSeparatedByString: @"\n"];
[pathCont removeObjectsInArray: hiddenList];
}
int i;
for (i = 0; i < [pathCont count]; i++) {
NSString *aFile = [pathCont objectAtIndex:i];
if ([self isVisible:aFile])
// code
}
...



- (BOOL)isVisible:(NSString *)path
{
if (([path hasPrefix:@"."]) || ([path characterAtIndex:([path length] - 1)] == 13)) return FALSE;

OSStatus err;
FSRef fileRef;
Boolean isDirectory;
err = FSPathMakeRef((UInt8 *)[path cStringUsingEncoding:NSASCIIStringEncoding], &fileRef, &isDirectory); // ? noErr : fnfErr;
CFBooleanRef isInvisible;
BOOL isVisible = YES;


if (noErr == err)
err = LSCopyItemAttribute(&fileRef, kLSRolesAll, kLSItemIsInvisible, (CFTypeRef *)&isInvisible);


    if (noErr == err) {
        isVisible = (CFBooleanGetValue(isInvisible) == FALSE);
        CFRelease(isInvisible);
    }
    return isVisible;
}

_______________________________________________

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/jstiles% 40blizzard.com


This email sent to email@hidden

_______________________________________________

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.