mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
SDL_GetPrefPath() now uses the organization on all platforms.
Even if that's not the general convention for a given platform.
This commit is contained in:
parent
298d3d627a
commit
28aa076c8b
@ -76,12 +76,12 @@ SDL_GetPrefPath(const char *org, const char *app)
|
|||||||
// !!! FIXME: is there a better way to do this?
|
// !!! FIXME: is there a better way to do this?
|
||||||
const char *home = SDL_getenv("HOME");
|
const char *home = SDL_getenv("HOME");
|
||||||
const char *append = "config/settings/";
|
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);
|
char *retval = (char *) SDL_malloc(len);
|
||||||
if (!retval) {
|
if (!retval) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
} else {
|
} 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
|
create_directory(retval, 0700); // BeOS api: creates missing dirs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,19 +73,17 @@ SDL_GetPrefPath(const char *org, const char *app)
|
|||||||
NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||||
char *retval = NULL;
|
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. */
|
if ([array count] > 0) { /* we only want the first item in the list. */
|
||||||
NSString *str = [array objectAtIndex:0];
|
NSString *str = [array objectAtIndex:0];
|
||||||
const char *base = [str fileSystemRepresentation];
|
const char *base = [str fileSystemRepresentation];
|
||||||
if (base) {
|
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);
|
retval = (char *) SDL_malloc(len);
|
||||||
if (retval == NULL) {
|
if (retval == NULL) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
} else {
|
} else {
|
||||||
char *ptr;
|
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++) {
|
for (ptr = retval+1; *ptr; ptr++) {
|
||||||
if (*ptr == '/') {
|
if (*ptr == '/') {
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
|
@ -178,14 +178,14 @@ SDL_GetPrefPath(const char *org, const char *app)
|
|||||||
if (envr[len - 1] == '/')
|
if (envr[len - 1] == '/')
|
||||||
append += 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);
|
retval = (char *) SDL_malloc(len);
|
||||||
if (!retval) {
|
if (!retval) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
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++) {
|
for (ptr = retval+1; *ptr; ptr++) {
|
||||||
if (*ptr == '/') {
|
if (*ptr == '/') {
|
||||||
|
Loading…
Reference in New Issue
Block a user