mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-06 07:38:38 +00:00
filesystem: Rename a variable named "append" that is actually prepending.
(Strictly speaking, this was probably meant to be an "append" to the home/base directory before the org/app name are appended to _that_, but it's definitely added to the absolute start of the string on Emscripten, so might as well make all of these match. Reference PR #15262.
This commit is contained in:
@@ -40,22 +40,22 @@ char *SDL_SYS_GetBasePath(void)
|
||||
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
|
||||
{
|
||||
#ifdef SDL_EMSCRIPTEN_PERSISTENT_PATH_STRING
|
||||
const char *append = SDL_EMSCRIPTEN_PERSISTENT_PATH_STRING;
|
||||
const char *prepend = SDL_EMSCRIPTEN_PERSISTENT_PATH_STRING;
|
||||
#else
|
||||
const char *append = "/libsdl";
|
||||
const char *prepend = "/libsdl";
|
||||
#endif
|
||||
char *result;
|
||||
char *ptr = NULL;
|
||||
const size_t len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 4;
|
||||
const size_t len = SDL_strlen(prepend) + SDL_strlen(org) + SDL_strlen(app) + 4;
|
||||
result = (char *)SDL_malloc(len);
|
||||
if (!result) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (*org) {
|
||||
SDL_snprintf(result, len, "%s/%s/%s/", append, org, app);
|
||||
SDL_snprintf(result, len, "%s/%s/%s/", prepend, org, app);
|
||||
} else {
|
||||
SDL_snprintf(result, len, "%s/%s/", append, app);
|
||||
SDL_snprintf(result, len, "%s/%s/", prepend, app);
|
||||
}
|
||||
|
||||
for (ptr = result + 1; *ptr; ptr++) {
|
||||
|
||||
@@ -69,19 +69,19 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app)
|
||||
{
|
||||
// !!! FIXME: is there a better way to do this?
|
||||
const char *home = SDL_getenv("HOME");
|
||||
const char *append = "/config/settings/";
|
||||
const char *prepend = "/config/settings/";
|
||||
size_t len = SDL_strlen(home);
|
||||
|
||||
if (!len || (home[len - 1] == '/')) {
|
||||
++append; // home empty or ends with separator, skip the one from append
|
||||
++prepend; // home empty or ends with separator, skip the one from prepend
|
||||
}
|
||||
len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
|
||||
len += SDL_strlen(prepend) + SDL_strlen(org) + SDL_strlen(app) + 3;
|
||||
char *result = (char *) SDL_malloc(len);
|
||||
if (result) {
|
||||
if (*org) {
|
||||
SDL_snprintf(result, len, "%s%s%s/%s/", home, append, org, app);
|
||||
SDL_snprintf(result, len, "%s%s%s/%s/", home, prepend, org, app);
|
||||
} else {
|
||||
SDL_snprintf(result, len, "%s%s%s/", home, append, app);
|
||||
SDL_snprintf(result, len, "%s%s%s/", home, prepend, app);
|
||||
}
|
||||
create_directory(result, 0700); // Haiku api: creates missing dirs
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app)
|
||||
* http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
*/
|
||||
const char *envr = SDL_getenv("XDG_DATA_HOME");
|
||||
const char *append;
|
||||
const char *prepend;
|
||||
char *result = NULL;
|
||||
char *ptr = NULL;
|
||||
|
||||
@@ -278,26 +278,26 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app)
|
||||
SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set");
|
||||
return NULL;
|
||||
}
|
||||
append = "/.local/share/";
|
||||
prepend = "/.local/share/";
|
||||
} else {
|
||||
append = "/";
|
||||
prepend = "/";
|
||||
}
|
||||
|
||||
size_t len = SDL_strlen(envr);
|
||||
if (envr[len - 1] == '/') {
|
||||
append += 1;
|
||||
prepend += 1;
|
||||
}
|
||||
|
||||
len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
|
||||
len += SDL_strlen(prepend) + SDL_strlen(org) + SDL_strlen(app) + 3;
|
||||
result = (char *)SDL_malloc(len);
|
||||
if (!result) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (*org) {
|
||||
(void)SDL_snprintf(result, len, "%s%s%s/%s/", envr, append, org, app);
|
||||
(void)SDL_snprintf(result, len, "%s%s%s/%s/", envr, prepend, org, app);
|
||||
} else {
|
||||
(void)SDL_snprintf(result, len, "%s%s%s/", envr, append, app);
|
||||
(void)SDL_snprintf(result, len, "%s%s%s/", envr, prepend, app);
|
||||
}
|
||||
|
||||
for (ptr = result + 1; *ptr; ptr++) {
|
||||
|
||||
Reference in New Issue
Block a user