Fixed bug 2072 - Make OS X's filesystem calls use -[NSString fileSystemRepresentation]
authorSam Lantinga <slouken@libsdl.org>
Mon, 21 Oct 2013 00:20:27 -0700
changeset 7866 42da269b7977
parent 7865 f2a42ca4ddf0
child 7867 d9d50f52a686
Fixed bug 2072 - Make OS X's filesystem calls use -[NSString fileSystemRepresentation] C.W. Betts The recommended way of getting a file name that POSIX file APIs can open in OS X when using an NSString is -[NSString fileSystemRepresentation]. However, the current filesystem API in hg uses -[NSString UTF8String].
src/filesystem/cocoa/SDL_sysfilesystem.m
--- a/src/filesystem/cocoa/SDL_sysfilesystem.m	Mon Oct 21 00:15:24 2013 -0700
+++ b/src/filesystem/cocoa/SDL_sysfilesystem.m	Mon Oct 21 00:20:27 2013 -0700
@@ -45,12 +45,12 @@
         baseType = "resource";
     }
     if (SDL_strcasecmp(baseType, "bundle")==0) {
-        base = [[bundle bundlePath] UTF8String];
+        base = [[bundle bundlePath] fileSystemRepresentation];
     } else if (SDL_strcasecmp(baseType, "parent")==0) {
-        base = [[[bundle bundlePath] stringByDeletingLastPathComponent] UTF8String];
+        base = [[[bundle bundlePath] stringByDeletingLastPathComponent] fileSystemRepresentation];
     } else {
         /* this returns the exedir for non-bundled  and the resourceDir for bundled apps */
-        base = [[bundle resourcePath] UTF8String];
+        base = [[bundle resourcePath] fileSystemRepresentation];
     }
     if (base) {
         const size_t len = SDL_strlen(base) + 2;
@@ -77,7 +77,7 @@
 
     if ([array count] > 0) {  /* we only want the first item in the list. */
         NSString *str = [array objectAtIndex:0];
-        const char *base = [str UTF8String];
+        const char *base = [str fileSystemRepresentation];
         if (base) {
             const size_t len = SDL_strlen(base) + SDL_strlen(app) + 3;
             retval = (char *) SDL_malloc(len);