Rev 11 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 11 | Rev 13 | ||
---|---|---|---|
Line 27... | Line 27... | ||
27 | if (strrchr (app_path, '\\') != NULL) |
27 | if (strrchr (app_path, '\\') != NULL) |
28 | *strrchr (app_path, '\\') = 0; |
28 | *strrchr (app_path, '\\') = 0; |
29 | } |
29 | } |
30 | return (app_path); |
30 | return (app_path); |
31 | } |
31 | } |
- | 32 | #define sys_getdatapath() sys_getbasepath () |
|
32 | #elif defined(__APPLE__) |
33 | #elif defined(__APPLE__) |
33 | #include <CoreFoundation/CoreFoundation.h> |
34 | #include <CoreFoundation/CoreFoundation.h> |
- | 35 | #include <sys/types.h> |
|
- | 36 | #include <sys/stat.h> |
|
- | 37 | #include <unistd.h> |
|
34 | #include <dlfcn.h> |
38 | #include <dlfcn.h> |
- | 39 | #include <pwd.h> |
|
35 | void MessageBox (void *handle, char *msg, char *title, int buttons) |
40 | void MessageBox (void *handle, char *msg, char *title, int buttons) |
36 | { |
41 | { |
37 | const void *keys[2]; |
42 | const void *keys[2]; |
38 | const void *values[2]; |
43 | const void *values[2]; |
39 | SInt32 result; |
44 | SInt32 result; |
Line 80... | Line 85... | ||
80 | if (strrchr (app_path, '/') != NULL) |
85 | if (strrchr (app_path, '/') != NULL) |
81 | *strrchr (app_path, '/') = 0; |
86 | *strrchr (app_path, '/') = 0; |
82 | strcat_s (app_path, 1024, "/Resources"); |
87 | strcat_s (app_path, 1024, "/Resources"); |
83 | } |
88 | } |
84 | return (app_path); |
89 | return (app_path); |
- | 90 | } |
|
- | 91 | char *sys_getdatapath (void) |
|
- | 92 | { |
|
- | 93 | static char data_path[1024] = ""; |
|
- | 94 | if (data_path[0] == 0) |
|
- | 95 | { |
|
- | 96 | // Pierre-Marie Baty -- macOS .app fix |
|
- | 97 | // peek in ~/Library/Application Support/<DOTTED BUNDLE ID> |
|
- | 98 | // if the directory doesn't exist, create it |
|
- | 99 | char bundle_id[256]; |
|
- | 100 | char *homedir = getenv ("HOME"); |
|
- | 101 | if (homedir == NULL) |
|
- | 102 | homedir = getpwuid (getuid ())->pw_dir; |
|
- | 103 | CFStringGetCString (CFBundleGetIdentifier (CFBundleGetMainBundle ()), bundle_id, sizeof (bundle_id), kCFStringEncodingUTF8); |
|
- | 104 | sprintf (data_path, "%s/Library/Application Support/%s", homedir, bundle_id); |
|
- | 105 | if (access (data_path, 0) != 0) |
|
- | 106 | mkdir (data_path, 0755); |
|
- | 107 | } |
|
- | 108 | return (data_path); |
|
85 | } |
109 | } |
86 | #else // !_WIN32 && !__APPLE__ |
110 | #else // !_WIN32 && !__APPLE__ |
87 | #define MessageBox(handle,msg,title,btns) fprintf (stderr, msg) |
111 | #define MessageBox(handle,msg,title,btns) fprintf (stderr, msg) |
88 | #define MB_OK 0 |
112 | #define MB_OK 0 |
89 | char *sys_getbasepath (void) |
113 | char *sys_getbasepath (void) |
90 | { |
114 | { |
91 | return ("."); |
115 | return ("."); |
92 | } |
116 | } |
- | 117 | #define sys_getdatapath() sys_getbasepath () |
|
93 | #endif // _WIN32 || __APPLE__ |
118 | #endif // _WIN32 || __APPLE__ |
94 | 119 | ||
95 | 120 | ||
96 | /* |
121 | /* |
97 | * Panic |
122 | * Panic |