10.6 compatibility: Fix some new compiler warnings, and work around apparent regressions in NSTask and -stringByStandardizingPath.
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];
59 Copyright (c) 2008, Jens Alfke <jens@mooseyard.com>. All rights reserved.
61 Redistribution and use in source and binary forms, with or without modification, are permitted
62 provided that the following conditions are met:
64 * Redistributions of source code must retain the above copyright notice, this list of conditions
65 and the following disclaimer.
66 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
67 and the following disclaimer in the documentation and/or other materials provided with the
70 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
71 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
72 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
73 BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
74 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
75 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
76 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
77 THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.