CFURLRef appURL = CFBundleCopyBundleURL( CFBundleGetMainBundle( ) );
CFStringRef appRef = CFURLCopyFileSystemPath( appURL,
kCFURLPOSIXPathStyle );
- CFIndex appLength = CFStringGetMaximumSizeForEncoding( CFStringGetLength(appRef),
- CFStringGetFastestEncoding( appRef ));
-
- char * appString = tr_malloc( appLength + 1 );
- bool success = CFStringGetCString( appRef,
- appString,
- appLength + 1,
- CFStringGetFastestEncoding( appRef ));
+ const CFIndex appStringLength = CFStringGetMaximumSizeOfFileSystemRepresentation(appRef);
+
+ char * appString = tr_malloc( appStringLength );
+ const bool success = CFStringGetFileSystemRepresentation( appRef, appString, appStringLength );
assert( success );
CFRelease( appURL );