Changed the macOS functionning so it is no more deprecated.#16
Conversation
cxong
left a comment
There was a problem hiding this comment.
this PR includes several changes like adding test script, replacing deprecated CoreServices, changing default file path etc, it might be better to split this PR so it can be reviewed easier
| #endif | ||
|
|
||
| #ifdef __cplusplus | ||
| namespace cfgpath { |
There was a problem hiding this comment.
I wouldn't add the namespace, it just makes the library usage different for C++ for not much gain
| /* Make the config folder if it doesn't already exist */ | ||
| mkdir(out, 0755); | ||
| strcat(out, PATH_SEPARATOR_STRING); | ||
| } |
There was a problem hiding this comment.
if glob fails need to set out[0] = '\0'; so the caller knows something went wrong
| * Windows: C:\Users\jcitizen\AppData\Roaming\appname.ini | ||
| * Linux: /home/jcitizen/.config/appname.conf | ||
| * Mac: /Users/jcitizen/Library/Application Support/appname.conf | ||
| * Mac: /Users/jcitizen/Library/Application Support/appname/appname.conf |
There was a problem hiding this comment.
while it is better practice for programs to put their files in a folder in application support, this will break backwards compatibility, so I think it's better to leave this unchanged
There was a problem hiding this comment.
Either that or add a #define to allow it to go into a subfolder across all platforms.
There was a problem hiding this comment.
Actually that's what get_user_config_folder() is for so better to leave it unchanged so it doesn't produce a filename that might conflict with what get_user_config_folder() returns.
I also created basic tests for macOS and a namespace when compiled in C++. On the previous version we needed to link to Cocoa framework to use the
FSFindFolderandFSRefMakePathfunctions but now the new functions live somewhere else (maybe in libc?)However while looking in
test-win.c, I saw that the user name of the paths were always "test-win" and that should lead to a failed test (I did not tested I don't have windows).