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
This commit is contained in:
Carsten Haitzler 2016-04-11 11:45:46 +09:00
parent 13059e96ba
commit eff86cd48a
2 changed files with 23 additions and 15 deletions

View File

@ -5,8 +5,8 @@ interface Efl.Vpath
"~/file.jpg" "~/file.jpg"
"~username/file.png" "~username/file.png"
And also other extended paths like: And also other extended paths like:
"(:cache/file.png" "(:cache:)/file.png"
"(:videos/file.mp4" "(:videos:)/file.mp4"
... ...
And in future: And in future:
"file:///blah.jpg" "file:///blah.jpg"

View File

@ -122,8 +122,8 @@ _efl_vpath_core_eo_base_constructor(Eo *obj, Efl_Vpath_Core_Data *pd)
// ^^^^ we don't handle: // ^^^^ we don't handle:
// /etc/xdg/user-dirs.conf // /etc/xdg/user-dirs.conf
// /etc/xdg/user-dirs.defaults // /etc/xdg/user-dirs.defaults
// (:config/user-dirs.conf // (:config:)/user-dirs.conf
// (:config/user-dirs.defaults // (:config:)/user-dirs.defaults
// $XDG_DESKTOP_DIR="$HOME/Desktop" // $XDG_DESKTOP_DIR="$HOME/Desktop"
ENV_HOME_SET("XDG_DESKTOP_DIR", "Desktop", "desktop"); 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
{ {
const char *p, *meta; const char *p, *meta;
char *name, buf[PATH_MAX]; char *name, buf[PATH_MAX];
Eina_Bool found = EINA_FALSE;
for (p = path + 2; *p; p++) for (p = path + 2; *p; p++)
{ {
if (*p =='/') break; if ((p[0] ==':') && (p[1] == ')') && (p[2] == '/'))
{
found = EINA_TRUE;
break;
}
} }
name = alloca(p - path); if (found)
strncpy(name, path + 2, p - path - 2);
name[p - path - 2] = 0;
eina_spinlock_take(&(pd->lock));
meta = eina_hash_find(pd->meta, name);
eina_spinlock_release(&(pd->lock));
if (meta)
{ {
snprintf(buf, sizeof(buf), "%s%s", meta, p); name = alloca(p - path);
efl_vpath_file_result_set(file, buf); strncpy(name, path + 2, p - path - 2);
return file; name[p - path - 2] = 0;
eina_spinlock_take(&(pd->lock));
meta = eina_hash_find(pd->meta, name);
eina_spinlock_release(&(pd->lock));
if (meta)
{
snprintf(buf, sizeof(buf), "%s%s", meta, p + 2);
efl_vpath_file_result_set(file, buf);
return file;
}
} }
} }
// file:/// <- local file path uri // file:/// <- local file path uri