diff options
author | Michael Pavone <pavone@retrodev.com> | 2016-07-30 23:36:02 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2016-07-30 23:36:02 -0700 |
commit | c879cacf40d18b3bc10ef576bfd9b1a73cb88555 (patch) | |
tree | 17bcd4b91fec694f47738f7a00a661bde563d42f /util.c | |
parent | 64cd8646221c9adee0da9f8b47b3e72c2ed0cbb2 (diff) |
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
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 34 |
1 files changed, 28 insertions, 6 deletions
@@ -593,13 +593,35 @@ char *read_bundled_file(char *name, long *sizeret) 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 @@ char const *get_save_dir() { 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; |