// NSFileManager+BundleBit.m // Created by Mac-arena the Bored Zo on 2005-10-31. // Copyright 2005 Adium Team. All rights reserved. #import "NSFileManager+BundleBit.h" #include <Carbon/Carbon.h> union FinderInfoTransmuter { struct FileInfo *finderInfo; @implementation NSFileManager (BundleBit) - (BOOL) bundleBitOfFile:(NSString *)path { const char *pathFSR = [path fileSystemRepresentation]; OSStatus err = FSPathMakeRef((const UInt8 *)pathFSR, &ref, /*isDirectory*/ NULL); struct FSCatalogInfo catInfo; union FinderInfoTransmuter finderInfoPointers = { .bytes = catInfo.finderInfo }; err = FSGetCatalogInfo(&ref, value = (finderInfoPointers.finderInfo->finderFlags) & kHasBundle; - (void) setBundleBitOfFile:(NSString *)path toBool:(BOOL)newValue { const char *pathFSR = [path fileSystemRepresentation]; OSStatus err = FSPathMakeRef((const UInt8 *)pathFSR, &ref, /*isDirectory*/ NULL); struct FSCatalogInfo catInfo; union FinderInfoTransmuter finderInfoPointers = { .bytes = catInfo.finderInfo }; err = FSGetCatalogInfo(&ref, finderInfoPointers.finderInfo->finderFlags |= kHasBundle; finderInfoPointers.finderInfo->finderFlags &= ~kHasBundle;