2009-06-10 15 views

答えて

5

FSPathMakeRefをお試しください:

NSString *path = @"Some... path... here"; 
FSRef f; 
OSStatus os_status = FSPathMakeRef((const UInt8 *)[path fileSystemRepresentation], &f, NULL); 

if (os_status == noErr) { 
    NSLog(@"Success"); 
} 
2

あなたはUTF-8 C文字列のパスからFSRefを作るためにFSPathMakeRef()を使用することができ、あなたがUTF-8 C文字列を取得するためにNSString-UTF8String方法を使用することができます。

FSRef fsref; 
Boolean isDirectory; 
OSStatus result = FSPathMakeRef([myString UTF8String], &fsref, &isDirectory); 
if(result < 0) 
    // handle error 
// If successful, fsref is valid, and isDirectory is true if the given path 
// is a directory. If you don't care about that, you can instead pass NULL 
// for the third argument of FSPathMakeRef() 
あなたは彼のNSString + NDCarbonUtilitiesカテゴリにネイサン日からこのメソッドを使用することができます
1

- (BOOL)getFSRef:(FSRef *)aFSRef 
{ 
    return FSPathMakeRef((const UInt8 *)[self fileSystemRepresentation], aFSRef, NULL) == noErr; 
} 

詳細については、NDAlias(http://homepage.mac.com/nathan_day/pages/source.xml)を参照してください(MITライセンス)。

関連する問題