filesystem: SDL_GetPrefPath() now follows the SDL_GetStringRule.

Reference Issue #10229.
This commit is contained in:
Ryan C. Gordon
2024-07-15 20:21:22 -04:00
parent 2321726ff1
commit 52bf7ff42d
20 changed files with 35 additions and 26 deletions

View File

@@ -429,6 +429,15 @@ const char *SDL_GetUserFolder(SDL_Folder folder)
}
const char *SDL_GetPrefPath(const char *org, const char *app)
{
char *path = SDL_SYS_GetPrefPath(org, app);
if (path) {
SDL_FreeLater(path);
}
return path;
}
void SDL_InitFilesystem(void)
{

View File

@@ -24,6 +24,7 @@
// return a string that we can SDL_free(). It will be cached at the higher level.
extern char *SDL_SYS_GetBasePath(void);
extern char *SDL_SYS_GetPrefPath(const char *org, const char *app);
extern char *SDL_SYS_GetUserFolder(SDL_Folder folder);
int SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_EnumerateDirectoryCallback cb, void *userdata);

View File

@@ -34,7 +34,7 @@ char *SDL_SYS_GetBasePath(void)
return NULL;
}
char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
const char *path = SDL_GetAndroidInternalStoragePath();
if (path) {

View File

@@ -61,7 +61,7 @@ char *SDL_SYS_GetBasePath(void)
}
}
char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
@autoreleasepool {
char *retval = NULL;

View File

@@ -31,7 +31,7 @@ char *SDL_SYS_GetBasePath(void)
return NULL;
}
char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
SDL_Unsupported();
return NULL;

View File

@@ -34,7 +34,7 @@ char *SDL_SYS_GetBasePath(void)
return SDL_strdup("/");
}
char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
const char *append = "/libsdl/";
char *retval;

View File

@@ -79,8 +79,7 @@ SDL_SYS_GetBasePath(void)
return path;
}
char *
SDL_GetPrefPath(const char *org, const char *app)
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
XUserHandle user = NULL;
XAsyncBlock block = { 0 };

View File

@@ -65,7 +65,7 @@ char *SDL_SYS_GetBasePath(void)
}
char *SDL_GetPrefPath(const char *org, const char *app)
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");

View File

@@ -38,7 +38,7 @@ char *SDL_SYS_GetBasePath(void)
return base_path;
}
char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
char *pref_path = NULL;
if (!app) {

View File

@@ -73,7 +73,7 @@ static void recursive_mkdir(const char *dir)
mkdir(tmp, S_IRWXU);
}
char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
char *retval = NULL;
size_t len;

View File

@@ -44,7 +44,7 @@ char *SDL_SYS_GetBasePath(void)
return retval;
}
char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
char *retval = NULL;
size_t len;

View File

@@ -150,7 +150,7 @@ char *SDL_SYS_GetBasePath(void)
return retval;
}
char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
char *canon, *dir, *retval;
size_t len;

View File

@@ -253,7 +253,7 @@ char *SDL_SYS_GetBasePath(void)
return retval;
}
char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
/*
* We use XDG's base directory spec, even if you're not on Linux.

View File

@@ -39,7 +39,7 @@ char *SDL_SYS_GetBasePath(void)
return SDL_strdup("app0:/");
}
char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
const char *envr = "ux0:/data/";
char *retval = NULL;

View File

@@ -90,7 +90,7 @@ char *SDL_SYS_GetBasePath(void)
return retval;
}
char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
/*
* Vista and later has a new API for this, but SHGetFolderPath works there,

View File

@@ -137,7 +137,7 @@ extern "C" char *SDL_SYS_GetBasePath(void)
return destPath;
}
extern "C" char *SDL_GetPrefPath(const char *org, const char *app)
extern "C" char *SDL_SYS_GetPrefPath(const char *org, const char *app)
{
/* WinRT note: The 'SHGetFolderPath' API that is used in Windows 7 and
* earlier is not available on WinRT or Windows Phone. WinRT provides