Re: How can i check if a file is hidden?
Re: How can i check if a file is hidden?
- Subject: Re: How can i check if a file is hidden?
- From: Eric Blair <email@hidden>
- Date: Tue, 10 Jun 2003 17:04:22 -0400
On 6/10/03 at 3:49 PM, Eric Blair <email@hidden> wrote:
>
On 6/10/03 at 8:06 PM, Jesus De Meyer <email@hidden> wrote:
>
>
>I check NSFileManager and I can't find anything on it. Even the
>
>attributes don't have what I need. I suppose I could check if the file
>
>starts with a dot, but not every file that's invisible starts with a
>
>dot.
>
>
Here's some code I use that checks both the Finder flag and whether the name
>
starts with a dot.
>
>
- (bool)fileVisible:(NSString *)filePath {
>
FSSpec fsSpec = [filePath getFSSpec];
>
FInfo fInfo;
>
>
OSStatus err = FSpGetFInfo(&fsSpec, &fInfo);
>
>
if(err)
>
return NO;
>
>
bool invisibleFlag = fInfo.fdFlags & kIsInvisible;
>
BOOL invisibleName = [[filePath lastPathComponent] hasPrefix:@"."];
>
>
bool fileVisible = !(invisibleFlag && invisibleName);
>
>
return visible
>
}
>
>
There's a third way files can be made invisible, but I don't recall it off the
>
top of my head and, obviously, this code doesn't check it.
>
Oh yes, you'll need the getFSSpec category for this to work. It's been a few
months since I used this code, so the dependency slipped my mind.
- (FSRef)getFSRef
{
FSRef fsRef;
OSStatus status = FSPathMakeRef([self fileSystemRepresentation],
&fsRef,
NULL);
return fsRef;
}
- (FSSpec)getFSSpec
{
FSSpec fsSpec;
FSRef fsRef;
fsRef = [self getFSRef];
OSStatus status = FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL,
&fsSpec, NULL);
return fsSpec;
}
--Eric
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.