summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-04-11 11:45:46 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-04-11 11:48:35 +0900
commiteff86cd48a9f01ace61aadcfcb8241ec426d6262 (patch)
tree66e746f71bdeda0ab5b3c028f65e1225a2c0fd25
parent13059e96ba1ca6cc1013e80901ac8fa1e3eabca3 (diff)
vpath - use double-happy format as poposed by onefang
vpath now uses a simley at the start and end of a special meta location. i.e.: (:home:)/blah.png (:app.data:)/blah.jpg
-rw-r--r--src/lib/efl/interfaces/efl_vpath.eo4
-rw-r--r--src/lib/efl/interfaces/efl_vpath_core.c34
2 files changed, 23 insertions, 15 deletions
diff --git a/src/lib/efl/interfaces/efl_vpath.eo b/src/lib/efl/interfaces/efl_vpath.eo
index 021b31790e..a622db6862 100644
--- a/src/lib/efl/interfaces/efl_vpath.eo
+++ b/src/lib/efl/interfaces/efl_vpath.eo
@@ -5,8 +5,8 @@ interface Efl.Vpath
5 "~/file.jpg" 5 "~/file.jpg"
6 "~username/file.png" 6 "~username/file.png"
7 And also other extended paths like: 7 And also other extended paths like:
8 "(:cache/file.png" 8 "(:cache:)/file.png"
9 "(:videos/file.mp4" 9 "(:videos:)/file.mp4"
10 ... 10 ...
11 And in future: 11 And in future:
12 "file:///blah.jpg" 12 "file:///blah.jpg"
diff --git a/src/lib/efl/interfaces/efl_vpath_core.c b/src/lib/efl/interfaces/efl_vpath_core.c
index d9aec6992f..6d7d422d36 100644
--- a/src/lib/efl/interfaces/efl_vpath_core.c
+++ b/src/lib/efl/interfaces/efl_vpath_core.c
@@ -122,8 +122,8 @@ _efl_vpath_core_eo_base_constructor(Eo *obj, Efl_Vpath_Core_Data *pd)
122 // ^^^^ we don't handle: 122 // ^^^^ we don't handle:
123 // /etc/xdg/user-dirs.conf 123 // /etc/xdg/user-dirs.conf
124 // /etc/xdg/user-dirs.defaults 124 // /etc/xdg/user-dirs.defaults
125 // (:config/user-dirs.conf 125 // (:config:)/user-dirs.conf
126 // (:config/user-dirs.defaults 126 // (:config:)/user-dirs.defaults
127 127
128 // $XDG_DESKTOP_DIR="$HOME/Desktop" 128 // $XDG_DESKTOP_DIR="$HOME/Desktop"
129 ENV_HOME_SET("XDG_DESKTOP_DIR", "Desktop", "desktop"); 129 ENV_HOME_SET("XDG_DESKTOP_DIR", "Desktop", "desktop");
@@ -324,22 +324,30 @@ _efl_vpath_core_efl_vpath_fetch(Eo *obj, Efl_Vpath_Core_Data *pd EINA_UNUSED, co
324 { 324 {
325 const char *p, *meta; 325 const char *p, *meta;
326 char *name, buf[PATH_MAX]; 326 char *name, buf[PATH_MAX];
327 Eina_Bool found = EINA_FALSE;
327 328
328 for (p = path + 2; *p; p++) 329 for (p = path + 2; *p; p++)
329 { 330 {
330 if (*p =='/') break; 331 if ((p[0] ==':') && (p[1] == ')') && (p[2] == '/'))
332 {
333 found = EINA_TRUE;
334 break;
335 }
331 } 336 }
332 name = alloca(p - path); 337 if (found)
333 strncpy(name, path + 2, p - path - 2);
334 name[p - path - 2] = 0;
335 eina_spinlock_take(&(pd->lock));
336 meta = eina_hash_find(pd->meta, name);
337 eina_spinlock_release(&(pd->lock));
338 if (meta)
339 { 338 {
340 snprintf(buf, sizeof(buf), "%s%s", meta, p); 339 name = alloca(p - path);
341 efl_vpath_file_result_set(file, buf); 340 strncpy(name, path + 2, p - path - 2);
342 return file; 341 name[p - path - 2] = 0;
342 eina_spinlock_take(&(pd->lock));
343 meta = eina_hash_find(pd->meta, name);
344 eina_spinlock_release(&(pd->lock));
345 if (meta)
346 {
347 snprintf(buf, sizeof(buf), "%s%s", meta, p + 2);
348 efl_vpath_file_result_set(file, buf);
349 return file;
350 }
343 } 351 }
344 } 352 }
345 // file:/// <- local file path uri 353 // file:/// <- local file path uri