summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-02-23 16:26:30 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-02-23 16:26:30 +0900
commit411e140eaf9f51b9018e089d42ec1c8a8b5419ed (patch)
treed6d4545f1157cbbeb3e6f5290218dcf8bfaf9372 /src/lib
parentbda5a0dd4ab730ddb3fbab90a38cdf33a807ae53 (diff)
eina vpath - improve docs and add app.tmp and usr.tmp vpaths too
definitely kaes the docs better with lots of sample paths and some indication of what these may map to in real life.
Diffstat (limited to '')
-rw-r--r--src/lib/efreet/efreet.c1
-rw-r--r--src/lib/eina/eina_internal.h1
-rw-r--r--src/lib/eina/eina_vpath.c18
-rw-r--r--src/lib/eina/eina_vpath.h90
4 files changed, 88 insertions, 22 deletions
diff --git a/src/lib/efreet/efreet.c b/src/lib/efreet/efreet.c
index eb29b55f72..9c22d6386a 100644
--- a/src/lib/efreet/efreet.c
+++ b/src/lib/efreet/efreet.c
@@ -86,6 +86,7 @@ _efreet_efreet_app_interface_set(void)
86 // not set or empty, a default equal to $HOME/.local/share should be 86 // not set or empty, a default equal to $HOME/.local/share should be
87 // used. 87 // used.
88 ENV_HOME_SET("XDG_DATA_HOME", ".local/share", data); 88 ENV_HOME_SET("XDG_DATA_HOME", ".local/share", data);
89 ENV_HOME_SET("XDG_TMP_HOME", ".local/tmp", tmp);
89 // $XDG_CONFIG_HOME defines the base directory relative to which user 90 // $XDG_CONFIG_HOME defines the base directory relative to which user
90 // specific configuration files should be stored. If $XDG_CONFIG_HOME 91 // specific configuration files should be stored. If $XDG_CONFIG_HOME
91 // is either not set or empty, a default equal to $HOME/.config should 92 // is either not set or empty, a default equal to $HOME/.config should
diff --git a/src/lib/eina/eina_internal.h b/src/lib/eina/eina_internal.h
index 0c5adbb1cd..9324118c91 100644
--- a/src/lib/eina/eina_internal.h
+++ b/src/lib/eina/eina_internal.h
@@ -59,6 +59,7 @@ struct _Eina_Vpath_Interface_User
59 const char *config; 59 const char *config;
60 const char *cache; 60 const char *cache;
61 const char *run; 61 const char *run;
62 const char *tmp;
62}; 63};
63 64
64/** 65/**
diff --git a/src/lib/eina/eina_vpath.c b/src/lib/eina/eina_vpath.c
index cb9ff972bb..9a31d74c58 100644
--- a/src/lib/eina/eina_vpath.c
+++ b/src/lib/eina/eina_vpath.c
@@ -35,7 +35,7 @@ _eina_vpath_data_get(const char *key)
35} 35}
36 36
37 37
38static char* 38static char *
39_fallback_runtime_dir(const char *home) 39_fallback_runtime_dir(const char *home)
40{ 40{
41 char buf[PATH_MAX]; 41 char buf[PATH_MAX];
@@ -109,7 +109,7 @@ _fallback_runtime_dir(const char *home)
109 return strdup(buf); 109 return strdup(buf);
110} 110}
111 111
112static char* 112static char *
113_fallback_home_dir() 113_fallback_home_dir()
114{ 114{
115 char buf[PATH_MAX]; 115 char buf[PATH_MAX];
@@ -178,7 +178,7 @@ eina_vpath_shutdown(void)
178 return EINA_TRUE; 178 return EINA_TRUE;
179} 179}
180 180
181EAPI char* 181EAPI char *
182eina_vpath_resolve(const char* path) 182eina_vpath_resolve(const char* path)
183{ 183{
184 // XXX: implement parse of path then look up in hash if not just create 184 // XXX: implement parse of path then look up in hash if not just create
@@ -306,14 +306,17 @@ eina_vpath_interface_app_set(const char *app_domain, Eina_Prefix *app_pfx)
306 _eina_vpath_data_add("app.data", eina_prefix_data_get(app_pfx)); 306 _eina_vpath_data_add("app.data", eina_prefix_data_get(app_pfx));
307 _eina_vpath_data_add("app.locale", eina_prefix_locale_get(app_pfx)); 307 _eina_vpath_data_add("app.locale", eina_prefix_locale_get(app_pfx));
308 snprintf(buf, sizeof(buf), "%s/%s", 308 snprintf(buf, sizeof(buf), "%s/%s",
309 _eina_vpath_data_get("config"), app_domain); 309 _eina_vpath_data_get("usr.config"), app_domain);
310 _eina_vpath_data_add("app.config", buf); 310 _eina_vpath_data_add("app.config", buf);
311 snprintf(buf, sizeof(buf), "%s/%s", 311 snprintf(buf, sizeof(buf), "%s/%s",
312 _eina_vpath_data_get("cache"), app_domain); 312 _eina_vpath_data_get("usr.cache"), app_domain);
313 _eina_vpath_data_add("app.cache", buf); 313 _eina_vpath_data_add("app.cache", buf);
314 snprintf(buf, sizeof(buf), "%s/%s", 314 snprintf(buf, sizeof(buf), "%s/%s",
315 _eina_vpath_data_get("data"), app_domain); 315 _eina_vpath_data_get("usr.data"), app_domain);
316 _eina_vpath_data_add("app.local", buf); 316 _eina_vpath_data_add("app.local", buf);
317 snprintf(buf, sizeof(buf), "%s/%s",
318 _eina_vpath_data_get("usr.tmp"), app_domain);
319 _eina_vpath_data_add("app.tmp", buf);
317} 320}
318 321
319EAPI void 322EAPI void
@@ -342,8 +345,9 @@ eina_vpath_interface_user_set(Eina_Vpath_Interface_User *user)
342 ADD(config); 345 ADD(config);
343 ADD(cache); 346 ADD(cache);
344 ADD(run); 347 ADD(run);
348 ADD(tmp);
345#undef ADD 349#undef ADD
346 350
347 if (free_run) 351 if (free_run)
348 free((char*)user->run); 352 free((char *)user->run);
349} 353}
diff --git a/src/lib/eina/eina_vpath.h b/src/lib/eina/eina_vpath.h
index 7927b4ad0b..36d1b595a4 100644
--- a/src/lib/eina/eina_vpath.h
+++ b/src/lib/eina/eina_vpath.h
@@ -3,29 +3,89 @@
3 3
4#include "eina_prefix.h" 4#include "eina_prefix.h"
5 5
6/* 6/**
7 * Eina_vpath 7 * Eina vpath is a path that can be prefixed with a virtual path.
8 * eina vpath is a path that can be prefixed with a virtual path.
9 * 8 *
10 * A virutla path can either start with (:XXXXXXXX:) that indicates a virtual path, OR normal with / or ./ or ../ or ~ 9 * A virutal path can either start with (:XXXXXXXX:) that indicates a virtual
11 * The char sequence in between (: and :) are used as key to lookup the real value. 10 * path with XXXXXXXX as the location, OR a normal path with / or a realative
12 * The key has to be set by a interface before, otherwise you will get a error. 11 * path like ./ or ../ or even shell common locatiors like ~/ or ~username/
12 *
13 * The string between (: and :) is used as key to lookup the real value.
14 * The key has to be set by an interface before, otherwise you will get an
15 * error.
16 *
17 * Sample paths:
18 *
19 * ~/myfiles/file.png
20 * ~bob/dir/file.txt
21 * /path/to/file.cfg
22 * ./file/relative/path.txt
23 * file/relative/path.txt
24 * (:tmp:)/some-temp-file/file.txt
25 * (:home:)/myfiles/file.png
26 *
27 * (:app.dir:)/bin/app-executable
28 * (:app.bin:)/app-executable-file
29 * (:app.lib:)/app-library.so
30 * (:app.data:)/application/datafile.png
31 * (:app.locale:)/en_US/LC_MESSAGES/app.mo
32 * (:app.config:)/application-config.xml
33 * (:app.local:)/application-data-file.jpg
34 * (:app.tmp:)/some-temp-file/path/file.txt
35 *
36 * (:usr.desktop:)/file-in-users-desktop-directory.txt
37 * (:usr.documents:)/letter-to-gradma.doc
38 * (:usr.downloads:)/file-downloaded-here.zip
39 * (:usr.music:)/fave-song.mp3
40 * (:usr.pictures:)/a-photo.,jpg
41 * (:usr.public:)/some-publicly-shared-file
42 * (:usr.templates:)/some-template-document.txt
43 * (:usr.videos:)/some-video-file.mp4
44 * (:usr.data:)/file-in-user-data-dir
45 * (:usr.config:)/file-in-user-conifg-dir
46 * (:usr.cache:)/file-in-user-cache-dir
47 * (:usr.run:)/file-in-xdg-runtime-dir
48 * (:usr.tmp:)/some-temp-file/path/file.txt
49 *
50 * Commonly mapped to real path (but may vary):
51 *
52 * (:tmp:) - /tmp
53 * (:home:) - ~/
54 *
55 * (:app.dir:) - /usr - (assuming app install PREFIX of /usr. may be /usr/local or others too)
56 * (:app.bin:) - /usr/bin - (almost always PREFIX/bin)
57 * (:app.lib:) - /usr/lib - (almost always PREFIX/lib)
58 * (:app.data:) - /usr/share/appname - (almost always PREIFX/share/appname)
59 * (:app.locale:) - /usr/share/locale - (almost always PREFIX/locale)
60 * (:app.config:) - ~/.config/appname
61 * (:app.local:) - ~/.local/share/appname
62 * (:app.tmp:) - ~/.local/tmp/appname
63 *
64 * (:usr.desktop:) - ~/Desktop
65 * (:usr.documents:) - ~/Documents
66 * (:usr.downloads:) - ~/Downloads
67 * (:usr.music:) - ~/Music
68 * (:usr.pictures:) - ~/Pictures
69 * (:usr.public:) - ~/Public
70 * (:usr.templates:) - ~/Templates
71 * (:usr.videos:) - ~/Videos
72 * (:usr.data:) - ~/.local/share
73 * (:usr.config:) - ~/.config
74 * (:usr.cache:) - ~/.cache
75 * (:usr.run:) - /var/run/user/1000
76 * (:usr.tmp:) - ~/.local/tmp
77 *
78 * Additional info: https://phab.enlightenment.org/w/eina_vpath/
13 * 79 *
14 * The symbol ~ is interpretated as the home directory of the running user, and will be replaced.
15 * Additional infos: https://phab.enlightenment.org/w/eina_vpath/
16 */
17
18/**
19 * This datatype is a vpath, this means you can use the syntax described above.
20 */ 80 */
21typedef const char* Eina_Vpath; 81typedef const char * Eina_Vpath;
22 82
23/* 83/*
24 * Translate a virtual path into a normal path. 84 * Translate a virtual path into a normal path.
25 * 85 *
26 * @return a string that is not virtual anymore 86 * @return NULL if failed, or a full normal string file path that is resolved
27 * 87 *
28 */ 88 */
29EAPI char* eina_vpath_resolve(Eina_Vpath path); 89EAPI char *eina_vpath_resolve(Eina_Vpath path);
30 90
31#endif 91#endif