From 4575f184a5aaf02f657e73d006fbd7f6e6aaae89 Mon Sep 17 00:00:00 2001 From: Mark Kim Date: Tue, 23 Mar 2021 21:15:50 -0400 Subject: [PATCH] ios export dir support --- src/ios.c | 7 +++++ src/ios.h | 1 + src/macos.c | 75 ++++++++++++++++++++++++++------------------------ src/macos.h | 1 + src/tuxpaint.c | 3 +- 5 files changed, 50 insertions(+), 37 deletions(-) diff --git a/src/ios.c b/src/ios.c index 1c7a682f5..d6e6249fe 100644 --- a/src/ios.c +++ b/src/ios.c @@ -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; +} diff --git a/src/ios.h b/src/ios.h index bef4f72c7..c263819a1 100644 --- a/src/ios.h +++ b/src/ios.h @@ -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__ */ diff --git a/src/macos.c b/src/macos.c index 4f311adc6..92dc5dbf5 100644 --- a/src/macos.c +++ b/src/macos.c @@ -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"); - - p = malloc(strlen(home) + strlen(MACOS_FONTS_PATH) + 1); - - if (p) - sprintf(p, MACOS_FONTS_PATH, getenv("HOME")); - else - perror("apple_fontsPath"); + if(!p) { + const char *home = getenv("HOME"); + + p = malloc(strlen(home) + strlen(MACOS_FONTS_PATH) + 1); + + 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; - - if (!p) - { - const char *home = getenv("HOME"); - - p = malloc(strlen(home) + strlen(MACOS_PREFERENCES_PATH) + 1); - - if (p) - sprintf(p, MACOS_PREFERENCES_PATH, getenv("HOME")); - else - perror("apple_preferencesPath"); + static char *p = NULL; + + if(!p) { + const char *home = getenv("HOME"); + + p = malloc(strlen(home) + strlen(MACOS_PREFERENCES_PATH) + 1); + + 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; } diff --git a/src/macos.h b/src/macos.h index a4170a091..f53ec1c20 100644 --- a/src/macos.h +++ b/src/macos.h @@ -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__ */ diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 9770c3e6c..60cce9a9e 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -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