• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
File system visiblilty
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

File system visiblilty


  • Subject: File system visiblilty
  • From: Justin Hawkwood <email@hidden>
  • Date: Wed, 14 Nov 2007 16:52:51 -0800

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: File system visiblilty
      • From: Rob Keniger <email@hidden>
    • Re: File system visiblilty
      • From: Rob Keniger <email@hidden>
    • Re: File system visiblilty
      • From: John Stiles <email@hidden>
  • Prev by Date: re: Core Data: Cross-Model Relationships
  • Next by Date: Re: File system visiblilty
  • Previous by thread: Re: Adding/removing managed objects: how to know the maximum index?
  • Next by thread: Re: File system visiblilty
  • Index(es):
    • Date
    • Thread