On 02/03/2010, at 1:34 PM, Graham Cox wrote:

> Thanks, though it doesn't compile. What the hell is:
> 
>        union FinderInfoTransmuter finderInfoPointers = { .bytes = 
> catInfo.finderInfo };


Never mind, I just got rid of it and cast the struct directly:

- (void) setBundleBitOfFile:(NSString*)path toBool:(BOOL)newValue
{
    const char* pathFSR = [path fileSystemRepresentation];
    FSRef               ref;
    OSStatus    err = FSPathMakeRef((const UInt8*)pathFSR, &ref, 
/*isDirectory*/ NULL);
        
    if (err == noErr)
    {
        struct FSCatalogInfo catInfo;
        err = FSGetCatalogInfo(&ref,
                               kFSCatInfoFinderInfo,
                               &catInfo,
                               /*outName*/ NULL,
                               /*FSSpec*/ NULL,
                               /*parentRef*/ NULL);
                
        if (err == noErr)
        {
            if (newValue)
                ((FolderInfo*)&catInfo.finderInfo)->finderFlags |=  kHasBundle;
            else
                ((FolderInfo*)&catInfo.finderInfo)->finderFlags &= ~kHasBundle;
                        
            FSSetCatalogInfo(&ref,
                             kFSCatInfoFinderInfo,
                             &catInfo);
        }
    }
}

Thanks - it does the job for me.

One small follow-up question though. I'm also trying to set the extension of 
this package file hidden by default, using:


[[NSFileManager defaultManager] setAttributes:[[self class] 
defaultFileAttributes] ofItemAtPath:[self path] error:&error];

Where the default attributes are:

+ (NSDictionary*)       defaultFileAttributes
{
        return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber 
numberWithBool:YES], NSFileExtensionHidden, nil];
        
}


But the extension is not hidden. Opening Get Info in the Finder, the "hide 
extension" checkbox is greyed out, though is is checked, as if the extension 
were hidden.

Any idea what's going on there?

--Graham





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to