• 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
Setting the bundle bit [Was: Re: UTI's and document packages]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Setting the bundle bit [Was: Re: UTI's and document packages]


  • Subject: Setting the bundle bit [Was: Re: UTI's and document packages]
  • From: Antonio Nunes <email@hidden>
  • Date: Tue, 27 Nov 2007 09:36:33 +0000


On 26 Nov 2007, at 19:21, Antonio Nunes wrote:

Glad you have found your own answer, but one thing you should
additionally do is set the 'bundle bit' of your documents.  This way,
the Finder will not show them as folders, even if your application is
not present (say if you send a document to someone that doesn't have
your app).

Thanks Sean. I'll look into that.

So, after looking for solutions I found some older code, but it used deprecated functions, so I had to adapt it. This is what I came up with for setting or clearing the bundle bit at a given path:


OSErr ANSetBundleBitAtPath(NSString *path, BOOL flag)
{
	FSRef fsRef;
	OSErr osErr;
	osErr=FSPathMakeRef((UInt8 *)[path UTF8String], &fsRef, NULL);
	if (!osErr) {
		FSCatalogInfo info;
		osErr=FSGetCatalogInfo(&fsRef,
							   kFSCatInfoFinderInfo,
							   &info,
							   NULL,
							   NULL,
							   NULL);
		if (!osErr) {
			FileInfo *fInfo = (FileInfo *)info.finderInfo;
			if (flag) {
				fInfo->finderFlags |= kHasBundle;
			} else {
				fInfo->finderFlags &= ~kHasBundle;
			}

			osErr = FSSetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &info);
		}
	}
	return osErr;
}

1. I'm not sure UTF8String for the path is the correct encoding.
2. The path could of course be either a folder or a file, but it shouldn't matter whether the code coerces it to FileInfo or FolderInfo in this case.
3. I take it there is no Apple provided Cocoa API for this purpose. (At least, I couldn't find any.)
4. Is there otherwise anything wrong with this code, or anything I should be aware of?


-António

----------------------------------------------------
It isn't so important to do great things,
as to do what you do with great love.
----------------------------------------------------



_______________________________________________

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: Setting the bundle bit [Was: Re: UTI's and document packages]
      • From: "Sean McBride" <email@hidden>
    • Re: Setting the bundle bit [Was: Re: UTI's and document packages]
      • From: Alastair Houghton <email@hidden>
References: 
 >UTI's and document packages (From: Antonio Nunes <email@hidden>)
 >Re: UTI's and document packages (From: "Sean McBride" <email@hidden>)
 >Re: UTI's and document packages (From: Antonio Nunes <email@hidden>)

  • Prev by Date: Re: NSArrayController Frustration
  • Next by Date: Re: Setting the bundle bit [Was: Re: UTI's and document packages]
  • Previous by thread: Re: UTI's and document packages
  • Next by thread: Re: Setting the bundle bit [Was: Re: UTI's and document packages]
  • Index(es):
    • Date
    • Thread