Initial checkin.
5 // Created by Jens Alfke on 1/14/08.
6 // Copyright 2008 Jens Alfke. All rights reserved.
12 OSStatus PathToFSRef( NSString *path, FSRef *fsRef )
14 NSCParameterAssert(path);
15 return FSPathMakeRef((const UInt8 *)[path UTF8String],fsRef,NULL);
18 OSStatus FSRefToPath( const FSRef *fsRef, NSString **outPath )
20 NSURL *url = (id) CFURLCreateFromFSRef(NULL,fsRef);
23 *outPath = [url path];
29 BOOL CheckOSErr( OSStatus err, NSError **error )
33 *error = [NSError errorWithDomain: NSOSStatusErrorDomain code: err userInfo: nil];
41 NSString* AppSupportDirectory()
43 static NSString *sPath;
45 NSString *dir = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
46 NSUserDomainMask, YES)
48 dir = [dir stringByAppendingPathComponent: [[NSBundle mainBundle] bundleIdentifier]];
49 if( ! [[NSFileManager defaultManager] fileExistsAtPath: dir]
50 && ! [[NSFileManager defaultManager] createDirectoryAtPath: dir attributes: nil] )
51 [NSException raise: NSGenericException format: @"Unable to create app support dir %@",dir];