I have a file system path in NSString, but I need FSRef for the system call that I will make. What is the best way to create FSRef?
Try FSPathMakeRef:
NSString *path = @"Some... path... here"; FSRef f; OSStatus os_status = FSPathMakeRef((const UInt8 *)[path fileSystemRepresentation], &f, NULL); if (os_status == noErr) { NSLog(@"Success"); }
You can use FSPathMakeRef()to make FSRefUTF-8 C from a string path, and you can use a -UTF8Stringmethod NSStringto get UTF-8 C string:
FSPathMakeRef()
FSRef
-UTF8String
NSString
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()
Nathan Day NSString + NDCarbonUtilities:
- (BOOL)getFSRef:(FSRef *)aFSRef { return FSPathMakeRef( (const UInt8 *)[self fileSystemRepresentation], aFSRef, NULL ) == noErr; }
. NDAlias http://homepage.mac.com/nathan_day/pages/source.xml ( MIT).
Source: https://habr.com/ru/post/1710194/More articles:ClickOnce Version Already Exists Posting Warning - clickonceКак загрузить изображение статических карт Google с помощью Javascript - javascriptControlling component size in Swing when resizing a frame - javaElmah and SQL Server 90 compatibility mode - elmahПолучите UITableView, чтобы не прокручивать и не увеличиваться в UIScrollView - objective-cBrowser API for browsers without IE - firefoxAccess Firefox Cache from XPCOM Component - c ++What does error 0xC02020C4 mean in SSIS? - sql-serverWebResource.axd - Invalid ViewState - asp.netEvent with AS3 text field change without fail - eventsAll Articles