From fe80300fa3bcbc553cadac02c9de09ab1d15d66f Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Wed, 17 Apr 2019 15:30:34 +0100 Subject: [PATCH] eina_vpath: port to Windows Test Plan: test example Reviewers: raster, cedric, zmike Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8633 --- src/lib/eina/eina_vpath.c | 1 + src/lib/eina/eina_vpath.h | 4 ++-- src/lib/eina/eina_vpath_xdg.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/lib/eina/eina_vpath.c b/src/lib/eina/eina_vpath.c index c74749c..16c4129 100644 --- a/src/lib/eina/eina_vpath.c +++ b/src/lib/eina/eina_vpath.c @@ -230,6 +230,7 @@ _fetch_user_homedir(char **str, const char *name, const char *error) #else ERR("User fetching is disabled on this system\nThe string was: %s", error); return EINA_FALSE; + (void) name; #endif } diff --git a/src/lib/eina/eina_vpath.h b/src/lib/eina/eina_vpath.h index d06cb43..77c1e35 100644 --- a/src/lib/eina/eina_vpath.h +++ b/src/lib/eina/eina_vpath.h @@ -36,7 +36,7 @@ * (:app.tmp:)/some-temp-file/path/file.txt * * (:usr.desktop:)/file-in-users-desktop-directory.txt - * (:usr.documents:)/letter-to-gradma.doc + * (:usr.documents:)/letter-to-grandma.doc * (:usr.downloads:)/file-downloaded-here.zip * (:usr.music:)/fave-song.mp3 * (:usr.pictures:)/a-photo.,jpg @@ -44,7 +44,7 @@ * (:usr.templates:)/some-template-document.txt * (:usr.videos:)/some-video-file.mp4 * (:usr.data:)/file-in-user-data-dir - * (:usr.config:)/file-in-user-conifg-dir + * (:usr.config:)/file-in-user-config-dir * (:usr.cache:)/file-in-user-cache-dir * (:usr.run:)/file-in-xdg-runtime-dir * (:usr.tmp:)/some-temp-file/path/file.txt diff --git a/src/lib/eina/eina_vpath_xdg.c b/src/lib/eina/eina_vpath_xdg.c index e6db4c2..9d1c320 100644 --- a/src/lib/eina/eina_vpath_xdg.c +++ b/src/lib/eina/eina_vpath_xdg.c @@ -21,6 +21,37 @@ eina_xdg_env_init(void) memset(&user, 0, sizeof(Eina_Vpath_Interface_User)); +#ifdef _WIN32 + +# define ENV_SET(_env, _dir, _meta) \ + char _meta [PATH_MAX + 128]; \ + char *_meta##env = _env; \ + char *_meta##dir = _dir; \ + if (_meta##env) \ + strcpy(_meta, getenv(_meta##env)); \ + else \ + strcpy(_meta, home); \ + if (_meta##dir) \ + strcat(_meta, _meta##dir); \ + s = _meta; \ + (&user)->_meta = s; + + ENV_SET(NULL, "\\Desktop", desktop); + ENV_SET(NULL, "\\Documents", documents); + ENV_SET(NULL, "\\Downloads", downloads); + ENV_SET(NULL, "\\Music", music); + ENV_SET(NULL, "\\Pictures", pictures); + ENV_SET("CommonProgramFiles", NULL, pub); + ENV_SET("APPDATA", "\\Microsoft\\Windows\\Templates", templates); + ENV_SET(NULL, "\\Videos", videos); + ENV_SET("LOCALAPPDATA", NULL, data); + ENV_SET("LOCALAPPDATA", "\\Temp", tmp); + ENV_SET("APPDATA", NULL, config); + ENV_SET("LOCALAPPDATA", NULL, cache); + ENV_SET("APPDATA", NULL, run); + +#else /* _WIN32 */ + # if defined(HAVE_GETUID) && defined(HAVE_GETEUID) # define ENV_HOME_SET(_env, _dir, _meta) \ char _meta [PATH_MAX + 128]; \ @@ -80,5 +111,7 @@ eina_xdg_env_init(void) else user.run = s; +#endif /* _WIN32 */ + eina_vpath_interface_user_set(&user); } -- 2.7.4