• 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: Forcing the package bit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Forcing the package bit


  • Subject: Re: Forcing the package bit
  • From: Graham Cox <email@hidden>
  • Date: Tue, 2 Mar 2010 14:06:57 +1100

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 (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: Forcing the package bit
      • From: Ken Thomases <email@hidden>
References: 
 >Forcing the package bit (From: Graham Cox <email@hidden>)
 >Re: Forcing the package bit (From: Neil Allain <email@hidden>)
 >Re: Forcing the package bit (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Forcing the package bit
  • Next by Date: Re: Menu Items
  • Previous by thread: Re: Forcing the package bit
  • Next by thread: Re: Forcing the package bit
  • Index(es):
    • Date
    • Thread