eina vpath: fix warning on Windows, as well as the public path

Differential Revision: https://phab.enlightenment.org/D8866
This commit is contained in:
Vincent Torri 2019-05-08 20:28:05 +00:00 committed by Marcel Hollerbach
parent c75415ae36
commit 59f8516ec5
1 changed files with 23 additions and 15 deletions

View File

@ -28,28 +28,36 @@ eina_xdg_env_init(void)
} while (0) } while (0)
#ifdef _WIN32 #ifdef _WIN32
# define ENV_SET(_env, _dir, _meta) \ # define ENV_DIR_SET(_env, _dir, _meta) \
char _meta[PATH_MAX + 128]; \ char _meta[PATH_MAX + 128]; \
if (_env) { \ if (_env) { \
s = getenv(_env); \ s = getenv(_env); \
if (!s) s = home; \ if (!s) s = home; \
} else s = home; \ } else s = home; \
if (_dir) FATAL_SNPRINTF(_meta, "vpath string '%s' truncated - fatal", "%s\\%s", s, (char *)_dir); \ FATAL_SNPRINTF(_meta, "vpath string '%s' truncated - fatal", "%s\\%s", s, (char *)_dir); \
else FATAL_SNPRINTF(_meta, "vpath string '%s' truncated - fatal", "%s\\", s); \
(&user)->_meta = _meta; (&user)->_meta = _meta;
ENV_SET(NULL, "Desktop", desktop); # define ENV_SET(_env, _meta) \
ENV_SET(NULL, "Documents", documents); char _meta[PATH_MAX + 128]; \
ENV_SET(NULL, "Downloads", downloads); if (_env) { \
ENV_SET(NULL, "Music", music); s = getenv(_env); \
ENV_SET(NULL, "Pictures", pictures); if (!s) s = home; \
ENV_SET("CommonProgramFiles", NULL, pub); } else s = home; \
ENV_SET("APPDATA", "Microsoft\\Windows\\Templates", templates); FATAL_SNPRINTF(_meta, "vpath string '%s' truncated - fatal", "%s\\", s); \
ENV_SET(NULL, "Videos", videos); (&user)->_meta = _meta;
ENV_SET("LOCALAPPDATA", NULL, data);
ENV_SET("LOCALAPPDATA", "Temp", tmp); ENV_DIR_SET(NULL, "Desktop", desktop);
ENV_SET("APPDATA", NULL, config); ENV_DIR_SET(NULL, "Documents", documents);
ENV_SET("LOCALAPPDATA", NULL, cache); ENV_DIR_SET(NULL, "Downloads", downloads);
ENV_DIR_SET(NULL, "Music", music);
ENV_DIR_SET(NULL, "Pictures", pictures);
ENV_SET("PUBLIC", pub);
ENV_DIR_SET("APPDATA", "Microsoft\\Windows\\Templates", templates);
ENV_DIR_SET(NULL, "Videos", videos);
ENV_SET("LOCALAPPDATA", data);
ENV_DIR_SET("LOCALAPPDATA", "Temp", tmp);
ENV_SET("APPDATA", config);
ENV_SET("LOCALAPPDATA", cache);
if (!(s = getenv("APPDATA"))) if (!(s = getenv("APPDATA")))
user.run = NULL; user.run = NULL;
else else