From 4ebf9ec4278aefd9f98ddf42b4e5dd8050c9ed84 Mon Sep 17 00:00:00 2001 From: "C.W. Betts" Date: Sat, 22 May 2021 11:43:49 -0600 Subject: [PATCH] macOS: Have the support directory be in Application support. --- src/wx-sdl2.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/wx-sdl2.c b/src/wx-sdl2.c index 1c5f96d..084a527 100644 --- a/src/wx-sdl2.c +++ b/src/wx-sdl2.c @@ -50,6 +50,8 @@ #include #include #undef pause +#include +#include #endif extern void creatediscimage_open(void *hwnd); @@ -241,6 +243,20 @@ void get_pcem_path(char *s, int size) #ifdef __linux wx_get_home_directory(s); strcat(s, ".pcem/"); +#elif defined(__APPLE__) + /*TODO: Use CoreFoundation functions to get proper directory, in case + the Application Support directory is different (I.E., with signing)*/ + wx_get_home_directory(s); + strcat(s, "Library/Application Support/PCem/"); + + struct stat st = {0}; + + // create ~/Library/Application Support/PCem/ + // if it doesn't exist + if (stat(s, &st) == -1) + { + mkdir(s, 0700); + } #else char* path = SDL_GetBasePath(); strcpy(s, path);