ios export dir support

This commit is contained in:
Mark Kim 2021-03-23 21:15:50 -04:00
parent 55ca7ed09f
commit 4575f184a5
5 changed files with 50 additions and 37 deletions

View file

@ -26,6 +26,7 @@
#define IOS_FONTS_PATH "../Library/Fonts"
#define IOS_PREFERENCES_PATH "../Library/Application Support/TuxPaint"
#define IOS_PICTURES_PATH "../Documents"
const char *apple_fontsPath(void)
@ -44,3 +45,9 @@ const char *apple_globalPreferencesPath(void)
{
return IOS_PREFERENCES_PATH;
}
const char *apple_picturesPath(void)
{
return IOS_PICTURES_PATH;
}

View file

@ -25,6 +25,7 @@
const char *apple_fontsPath(void);
const char *apple_preferencesPath(void);
const char *apple_globalPreferencesPath(void);
const char *apple_picturesPath(void);
#endif /* __IOS_H__ */

View file

@ -27,58 +27,61 @@
#define MACOS_FONTS_PATH "%s/Library/Fonts"
#define MACOS_PREFERENCES_PATH "%s/Library/Application Support/TuxPaint"
#define MACOS_GLOBAL_PREFERENCES_PATH "/Library/Application Support/TuxPaint"
#define MACOS_PICTURES_PATH "%s/Pictures"
/**
* FIXME
*/
const char *apple_fontsPath(void)
{
static char *p = NULL;
static char *p = NULL;
if (!p)
{
const char *home = getenv("HOME");
if(!p) {
const char *home = getenv("HOME");
p = malloc(strlen(home) + strlen(MACOS_FONTS_PATH) + 1);
p = malloc(strlen(home) + strlen(MACOS_FONTS_PATH) + 1);
if (p)
sprintf(p, MACOS_FONTS_PATH, getenv("HOME"));
else
perror("apple_fontsPath");
if(p) sprintf(p, MACOS_FONTS_PATH, getenv("HOME"));
else perror("apple_fontsPath");
}
return p;
return p;
}
/**
* FIXME
*/
const char *apple_preferencesPath(void)
{
static char *p = NULL;
static char *p = NULL;
if (!p)
{
const char *home = getenv("HOME");
if(!p) {
const char *home = getenv("HOME");
p = malloc(strlen(home) + strlen(MACOS_PREFERENCES_PATH) + 1);
p = malloc(strlen(home) + strlen(MACOS_PREFERENCES_PATH) + 1);
if (p)
sprintf(p, MACOS_PREFERENCES_PATH, getenv("HOME"));
else
perror("apple_preferencesPath");
if(p) sprintf(p, MACOS_PREFERENCES_PATH, getenv("HOME"));
else perror("apple_preferencesPath");
}
return p;
return p;
}
/**
* FIXME
*/
const char *apple_globalPreferencesPath(void)
{
return MACOS_GLOBAL_PREFERENCES_PATH;
return MACOS_GLOBAL_PREFERENCES_PATH;
}
const char *apple_picturesPath(void)
{
static char *p = NULL;
if(!p) {
const char *home = getenv("HOME");
p = malloc(strlen(home) + strlen(MACOS_PICTURES_PATH) + 1);
if(p) sprintf(p, MACOS_PICTURES_PATH, getenv("HOME"));
else perror("apple_picturesPath");
}
return p;
}

View file

@ -25,6 +25,7 @@
const char *apple_fontsPath(void);
const char *apple_preferencesPath(void);
const char *apple_globalPreferencesPath(void);
const char *apple_picturesPath(void);
#endif /* __MACOS_H__ */

View file

@ -23392,10 +23392,11 @@ static void setup_config(char *argv[])
/* FIXME: Need assist for:
* __BEOS__
* __HAIKU__
* __APPLE__
*/
#ifdef WIN32
picturesdir = GetUserImageDir();
#elif __APPLE__
picturesdir = apple_picturesPath();
#else
picturesdir = get_xdg_user_dir("PICTURES", "Pictures");
#endif