I used to think that folders needed to have an extension so that they are recognized as packages by the Finder. That extension would be declared in the owning application\'s Inf
File and protocol are, to the best of my knowledge, only setup inside your apps Info.plist.
Apps get scanned, and the info in their plists get's added to LaunchServices settings.
Linkinus has 6 different Document Types declared, TextMate has 97, and CyberDuck has 3. I'll do some more searching but I think this is likely the preferred method.
There are two commands that may be of interest:
GetFileInfo iPhoto\ Library
attributes: avBstclinmedz
The B says that the "bundle" bit is set. The SetFile
command lets you set them. These let you access the extended attributes in HFS+ (per the man page).
Here are the possible attributes:
A Alias file
B Bundle
C Custom icon*
D Desktop*
E Hidden extension*
I Inited*
M Shared (can run multiple times)
N No INIT resources
L Locked
S System (name locked)
T Stationery
V Invisible*
Z Busy*
Although you should not rely solely upon it, one thing to do is set the file's bundle bit. I've got a category on NSWorkspace to do just that:
- (void)setBundleBit:(BOOL)flag forFile:(NSString *)path
{
FSRef fileRef;
OSErr error = FSPathMakeRef((UInt8 *)[path fileSystemRepresentation], &fileRef, NULL);
// Get the file's current info
FSCatalogInfo fileInfo;
if (!error)
{
error = FSGetCatalogInfo(&fileRef, kFSCatInfoFinderInfo, &fileInfo, NULL, NULL, NULL);
}
if (!error)
{
// Adjust the bundle bit
FolderInfo *finderInfo = (FolderInfo *)fileInfo.finderInfo;
if (flag) {
finderInfo->finderFlags |= kHasBundle;
}
else {
finderInfo->finderFlags &= ~kHasBundle;
}
// Set the altered flags of the file
error = FSSetCatalogInfo(&fileRef, kFSCatInfoFinderInfo, &fileInfo);
}
if (error) {
NSLog(@"OSError %i in -[NSWorkspace setBundleBit:forFile:]", error);
}
}