SDL_GetPrefPath() now uses the organization on all platforms.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 23 Oct 2013 00:58:20 -0400
changeset 7883 62f562a475e1
parent 7882 b81e4cc2932e
child 7884 15027aa2cf21
SDL_GetPrefPath() now uses the organization on all platforms. Even if that's not the general convention for a given platform.
src/filesystem/beos/SDL_sysfilesystem.cc
src/filesystem/cocoa/SDL_sysfilesystem.m
src/filesystem/unix/SDL_sysfilesystem.c
--- a/src/filesystem/beos/SDL_sysfilesystem.cc	Tue Oct 22 21:54:52 2013 -0700
+++ b/src/filesystem/beos/SDL_sysfilesystem.cc	Wed Oct 23 00:58:20 2013 -0400
@@ -76,12 +76,12 @@
     // !!! FIXME: is there a better way to do this?
     const char *home = SDL_getenv("HOME");
     const char *append = "config/settings/";
-    const size_t len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(app) + 2;
+    const size_t len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
     char *retval = (char *) SDL_malloc(len);
     if (!retval) {
         SDL_OutOfMemory();
     } else {
-        SDL_snprintf(retval, len, "%s%s%s/", home, append, app);
+        SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org, app);
         create_directory(retval, 0700);  // BeOS api: creates missing dirs
     }
 
--- a/src/filesystem/cocoa/SDL_sysfilesystem.m	Tue Oct 22 21:54:52 2013 -0700
+++ b/src/filesystem/cocoa/SDL_sysfilesystem.m	Wed Oct 23 00:58:20 2013 -0400
@@ -73,19 +73,17 @@
     NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
     char *retval = NULL;
 
-    (void) org;  /* unused on Mac OS X and iOS. */
-
     if ([array count] > 0) {  /* we only want the first item in the list. */
         NSString *str = [array objectAtIndex:0];
         const char *base = [str fileSystemRepresentation];
         if (base) {
-            const size_t len = SDL_strlen(base) + SDL_strlen(app) + 3;
+            const size_t len = SDL_strlen(base) + SDL_strlen(app) + 4;
             retval = (char *) SDL_malloc(len);
             if (retval == NULL) {
                 SDL_OutOfMemory();
             } else {
                 char *ptr;
-                SDL_snprintf(retval, len, "%s/%s/", base, app);
+                SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app);
                 for (ptr = retval+1; *ptr; ptr++) {
                     if (*ptr == '/') {
                         *ptr = '\0';
--- a/src/filesystem/unix/SDL_sysfilesystem.c	Tue Oct 22 21:54:52 2013 -0700
+++ b/src/filesystem/unix/SDL_sysfilesystem.c	Wed Oct 23 00:58:20 2013 -0400
@@ -178,14 +178,14 @@
     if (envr[len - 1] == '/')
         append += 1;
 
-    len += SDL_strlen(append) + SDL_strlen(app) + 2;
+    len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
     retval = (char *) SDL_malloc(len);
     if (!retval) {
         SDL_OutOfMemory();
         return NULL;
     }
 
-    SDL_snprintf(retval, len, "%s%s%s/", envr, append, app);
+    SDL_snprintf(retval, len, "%s%s%s/%s/", envr, append, org, app);
 
     for (ptr = retval+1; *ptr; ptr++) {
         if (*ptr == '/') {