# HG changeset patch # User Michael Pavone # Date 1469946962 25200 # Node ID 266dc3f31f35319a18ca073087a35fb2a41e9a0f # Parent ff46d8fc2de876b59f999ba31c7f05abd361c0a1 Use more appropriate paths for save directories and config files on Windows. Got rid of what should be the last vestiges of hard-coded path separators diff -r ff46d8fc2de8 -r 266dc3f31f35 util.c --- a/util.c Sat Jul 30 16:01:57 2016 -0700 +++ b/util.c Sat Jul 30 23:36:02 2016 -0700 @@ -593,13 +593,35 @@ return ret; } + +#ifdef _WIN32 +char const *get_save_base_dir() +{ + static char path[MAX_PATH]; + if (S_OK == SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path)) + { + return path; + } + return NULL; +} +#define CONFIG_PREFIX "" +#define SAVE_PREFIX "" + +#else + +#define get_save_base_dir get_home_dir +#define CONFIG_PREFIX "/.config" +#define SAVE_PREFIX "/.local/share" + +#endif + char const *get_config_dir() { static char* confdir; if (!confdir) { - char *homedir = get_home_dir(); - if (homedir) { - confdir = alloc_concat(homedir, "/.config/blastem"); + char const *base = get_save_base_dir(); + if (base) { + confdir = alloc_concat(base, CONFIG_PREFIX PATH_SEP "blastem"); } } return confdir; @@ -609,9 +631,9 @@ { static char* savedir; if (!savedir) { - char *homedir = get_home_dir(); - if (homedir) { - savedir = alloc_concat(homedir, "/.local/share/blastem"); + char const *base = get_save_base_dir(); + if (base) { + savedir = alloc_concat(base, SAVE_PREFIX PATH_SEP "blastem"); } } return savedir;