• 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
Re: NSFileManager fun & games
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSFileManager fun & games


  • Subject: Re: NSFileManager fun & games
  • From: Brendan Younger <email@hidden>
  • Date: Wed, 1 Dec 2004 09:21:42 -0600

There is an extremely easy way to find out whether a file should be hidden or not, use LSCopyItemInfoForRef() and look at the kLSItemInfoIsInvisible bit in the flags field. Not to mention it will probably continue to work correctly if Apple ever decides to make files invisible based on other criteria.

Brendan Younger

On Dec 1, 2004, at 4:54 AM, Jeremy Dronfield wrote:

On 1 Dec 2004, at 8:04 am, Charles Srstka wrote:

On Dec 1, 2004, at 12:29 AM, Duncan Campbell wrote:

I would like to only produce the list of files/folder you get when you click on the "Macintosh HD" icon on the desktop - i.e. beginning with "Applications", not showing any of the "." files/folders (hidden) etc.... - is there a method to produce this list?


Obviously I could just look for a "." as the 1st char of the filename, but it seems there would be a method that gives me what i am after, based on permissions etc?

I haven't tried it myself, but - [NSFileManager componentsToDisplayForPath:] looks like it might be what you need.

<snip>

- (BOOL)isVisibleFileAtPath:(NSString *)path {
BOOL visible = YES;
if ([[path lastPathComponent] hasPrefix:@"."]) {
visible = NO;
} else {
// check if file is in .hidden
NSString *hiddenFile = [NSString stringWithContentsOfFile:@"/.hidden"];
NSArray *dotHiddens = [hiddenFile componentsSeparatedByString:@"\n"];
visible = ![dotHiddens containsObject:[path lastPathComponent]];

// use Carbon to check if file has kIsInvisible finder flag
FSRef possibleInvisibleFile;
FSCatalogInfo catalogInfo;
OSStatus errStat = FSPathMakeRef([path fileSystemRepresentation], &possibleInvisibleFile, nil);
FSGetCatalogInfo(&possibleInvisibleFile, kFSCatInfoFinderInfo, &catalogInfo, nil, nil, nil);
if (((FileInfo*)catalogInfo.finderInfo)->finderFlags & kIsInvisible)
visible = NO;
}

return visible;
}

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: NSFileManager fun & games (From: Charles Srstka <email@hidden>)
 >Re: NSFileManager fun & games (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: Re: Resize NSTableView controle at Runtime.
  • Next by Date: Highlight table row like Mail or Finder?
  • Previous by thread: Re: NSFileManager fun & games
  • Next by thread: Off-screen Printing
  • Index(es):
    • Date
    • Thread