eina_vpath: port to Windows
authorVincent Torri <vincent.torri@gmail.com>
Wed, 17 Apr 2019 14:30:34 +0000 (15:30 +0100)
committerYeongjong Lee <yj34.lee@samsung.com>
Wed, 24 Apr 2019 05:24:47 +0000 (14:24 +0900)
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
src/lib/eina/eina_vpath.h
src/lib/eina/eina_vpath_xdg.c

index c74749c..16c4129 100644 (file)
@@ -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
 }
 
index d06cb43..77c1e35 100644 (file)
@@ -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
index e6db4c2..9d1c320 100644 (file)
@@ -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);
 }