//IconFamily depends heavily upon Carbon calls and thus will only work in Mac OS X #ifdef MAC_OS_X_VERSION_10_0 #import "NSString+CarbonFSSpecCreation.h" @implementation NSString (CarbonFSSpecCreation) - (BOOL) getFSRef:(FSRef*)fsRef createFileIfNecessary:(BOOL)createFile NSFileManager* fileManager = [NSFileManager defaultManager]; // Check whether the file exists already. If not, create an empty file if requested. if (![fileManager fileExistsAtPath:self]) { if (![@"" writeToFile:self atomically:YES]) { // Create a CFURL with the specified POSIX path. urlRef = CFURLCreateWithFileSystemPath( kCFAllocatorDefault, FALSE /* isDirectory */ ); // printf( "** Couldn't make a CFURLRef for the file.\n" ); // Try to create an FSRef from the URL. (If the specified file doesn't exist, this // function will return false, but if we've reached this code we've already insured // that the file exists.) gotFSRef = CFURLGetFSRef( urlRef, fsRef ); // printf( "** Couldn't get an FSRef for the file.\n" ); - (BOOL) getFSSpec:(FSSpec*)fsSpec createFileIfNecessary:(BOOL)createFile if (![self getFSRef:&fsRef createFileIfNecessary:createFile]) if (FSGetCatalogInfo( &fsRef, // printf( "** Couldn't get an FSSpec for the file.\n" ); + (NSString *)pathForFSRef:(FSRef *)object UInt8 *pathbuf = malloc(PATH_MAX); OSStatus err = FSRefMakePath(object, pathbuf, PATH_MAX); path = [(NSString *)CFStringCreateWithCString(kCFAllocatorDefault, (char *)pathbuf, kCFStringEncodingUTF8) autorelease];