forked from enlightenment/efl
efreet: remove realpath
Use eina_file_path_sanitize where needed SVN revision: 78161
This commit is contained in:
parent
8009998bcc
commit
2a3cb2d1c9
|
@ -367,8 +367,7 @@ efreet_dirs_get(const char *key, const char *fallback)
|
|||
{
|
||||
Eina_List *dirs = NULL;
|
||||
const char *path;
|
||||
char *tmp, *s, *p;
|
||||
// char ts[PATH_MAX];
|
||||
char *s, *p;
|
||||
size_t len;
|
||||
|
||||
path = getenv(key);
|
||||
|
@ -377,20 +376,20 @@ efreet_dirs_get(const char *key, const char *fallback)
|
|||
if (!path) return dirs;
|
||||
|
||||
len = strlen(path) + 1;
|
||||
tmp = alloca(len);
|
||||
memcpy(tmp, path, len);
|
||||
s = tmp;
|
||||
s = alloca(len);
|
||||
memcpy(s, path, len);
|
||||
p = strchr(s, EFREET_PATH_SEP);
|
||||
while (p)
|
||||
{
|
||||
*p = '\0';
|
||||
if (!eina_list_search_unsorted(dirs, EINA_COMPARE_CB(strcmp), s))
|
||||
{
|
||||
// resolve path properly/fully to remove path//path2 to
|
||||
// path/path2, path/./path2 to path/path2 etc.
|
||||
// if (realpath(s, ts))
|
||||
// dirs = eina_list_append(dirs, (void *)eina_stringshare_add(ts));
|
||||
dirs = eina_list_append(dirs, (void *)eina_stringshare_add(s));
|
||||
char *tmp = eina_file_path_sanitize(s);
|
||||
if (tmp)
|
||||
{
|
||||
dirs = eina_list_append(dirs, eina_stringshare_add(tmp));
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
s = ++p;
|
||||
|
@ -398,11 +397,12 @@ efreet_dirs_get(const char *key, const char *fallback)
|
|||
}
|
||||
if (!eina_list_search_unsorted(dirs, EINA_COMPARE_CB(strcmp), s))
|
||||
{
|
||||
// resolve path properly/fully to remove path//path2 to
|
||||
// path/path2, path/./path2 to path/path2 etc.
|
||||
// if (realpath(s, ts))
|
||||
// dirs = eina_list_append(dirs, (void *)eina_stringshare_add(ts));
|
||||
dirs = eina_list_append(dirs, (void *)eina_stringshare_add(s));
|
||||
char *tmp = eina_file_path_sanitize(s);
|
||||
if (tmp)
|
||||
{
|
||||
dirs = eina_list_append(dirs, eina_stringshare_add(tmp));
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
return dirs;
|
||||
|
|
|
@ -803,14 +803,10 @@ Efreet_Desktop *
|
|||
efreet_cache_desktop_find(const char *file)
|
||||
{
|
||||
Efreet_Cache_Desktop *cache;
|
||||
// char rp[PATH_MAX];
|
||||
const char *rp = file;
|
||||
|
||||
// if (!realpath(file, rp)) return NULL;
|
||||
|
||||
if (!efreet_cache_check(&desktop_cache, efreet_desktop_cache_file(), EFREET_DESKTOP_CACHE_MAJOR)) return NULL;
|
||||
|
||||
cache = eina_hash_find(desktops, rp);
|
||||
cache = eina_hash_find(desktops, file);
|
||||
if (cache == NON_EXISTING) return NULL;
|
||||
if (cache)
|
||||
{
|
||||
|
@ -829,11 +825,11 @@ efreet_cache_desktop_find(const char *file)
|
|||
|
||||
/* We got stale data. The desktop will be free'd eventually as
|
||||
* users will call efreet_desktop_free */
|
||||
eina_hash_set(desktops, rp, NON_EXISTING);
|
||||
eina_hash_set(desktops, file, NON_EXISTING);
|
||||
cache = NULL;
|
||||
}
|
||||
|
||||
cache = eet_data_read(desktop_cache, efreet_desktop_edd(), rp);
|
||||
cache = eet_data_read(desktop_cache, efreet_desktop_edd(), file);
|
||||
if (cache)
|
||||
{
|
||||
if (cache->desktop.load_time != ecore_file_mod_time(cache->desktop.orig_path))
|
||||
|
@ -841,7 +837,7 @@ efreet_cache_desktop_find(const char *file)
|
|||
/* Don't return stale data */
|
||||
INF("We got stale data in the desktop cache");
|
||||
efreet_cache_desktop_free(&cache->desktop);
|
||||
eina_hash_set(desktops, rp, NON_EXISTING);
|
||||
eina_hash_set(desktops, file, NON_EXISTING);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -852,7 +848,7 @@ efreet_cache_desktop_find(const char *file)
|
|||
}
|
||||
}
|
||||
else
|
||||
eina_hash_set(desktops, rp, NON_EXISTING);
|
||||
eina_hash_set(desktops, file, NON_EXISTING);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,10 +216,15 @@ EAPI Efreet_Desktop *
|
|||
efreet_desktop_new(const char *file)
|
||||
{
|
||||
Efreet_Desktop *desktop = NULL;
|
||||
char *tmp;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
|
||||
|
||||
desktop = efreet_cache_desktop_find(file);
|
||||
tmp = eina_file_path_sanitize(file);
|
||||
if (!tmp) return NULL;
|
||||
|
||||
desktop = efreet_cache_desktop_find(tmp);
|
||||
free(tmp);
|
||||
if (desktop)
|
||||
{
|
||||
desktop->ref++;
|
||||
|
@ -229,7 +234,6 @@ efreet_desktop_new(const char *file)
|
|||
return NULL;
|
||||
}
|
||||
return desktop;
|
||||
efreet_desktop_free(desktop);
|
||||
}
|
||||
return efreet_desktop_uncached_new(file);
|
||||
}
|
||||
|
@ -238,17 +242,21 @@ EAPI Efreet_Desktop *
|
|||
efreet_desktop_uncached_new(const char *file)
|
||||
{
|
||||
Efreet_Desktop *desktop = NULL;
|
||||
// char rp[PATH_MAX];
|
||||
const char *rp = file;
|
||||
char *tmp;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
|
||||
if (!ecore_file_exists(file)) return NULL;
|
||||
|
||||
// if (!realpath(file, rp)) return NULL;
|
||||
if (!ecore_file_exists(rp)) return NULL;
|
||||
tmp = eina_file_path_sanitize(file);
|
||||
if (!tmp) return NULL;
|
||||
|
||||
desktop = NEW(Efreet_Desktop, 1);
|
||||
if (!desktop) return NULL;
|
||||
desktop->orig_path = strdup(rp);
|
||||
if (!desktop)
|
||||
{
|
||||
free(tmp);
|
||||
return NULL;
|
||||
}
|
||||
desktop->orig_path = tmp;
|
||||
desktop->ref = 1;
|
||||
if (!efreet_desktop_read(desktop))
|
||||
{
|
||||
|
@ -1037,13 +1045,9 @@ efreet_desktop_changes_listen_recursive(const char *path)
|
|||
static void
|
||||
efreet_desktop_changes_monitor_add(const char *path)
|
||||
{
|
||||
// char rp[PATH_MAX];
|
||||
const char *rp = path;
|
||||
|
||||
// if (!realpath(path, rp)) return;
|
||||
if (eina_hash_find(change_monitors, rp)) return;
|
||||
eina_hash_add(change_monitors, rp,
|
||||
ecore_file_monitor_add(rp,
|
||||
if (eina_hash_find(change_monitors, path)) return;
|
||||
eina_hash_add(change_monitors, path,
|
||||
ecore_file_monitor_add(path,
|
||||
efreet_desktop_changes_cb,
|
||||
NULL));
|
||||
}
|
||||
|
|
|
@ -852,36 +852,27 @@ efreet_icon_changes_listen(void)
|
|||
static void
|
||||
efreet_icon_changes_monitor_add(const char *path)
|
||||
{
|
||||
// char rp[PATH_MAX];
|
||||
// if (!realpath(path, rp)) return;
|
||||
const char *rp = path;
|
||||
Eina_Iterator *it;
|
||||
const char *ent;
|
||||
|
||||
if (!ecore_file_is_dir(rp)) return;
|
||||
if (eina_hash_find(change_monitors, rp)) return;
|
||||
eina_hash_add(change_monitors, rp,
|
||||
ecore_file_monitor_add(rp,
|
||||
if (!ecore_file_is_dir(path)) return;
|
||||
if (eina_hash_find(change_monitors, path)) return;
|
||||
eina_hash_add(change_monitors, path,
|
||||
ecore_file_monitor_add(path,
|
||||
efreet_icon_changes_cb,
|
||||
NULL));
|
||||
|
||||
if (ecore_file_is_dir(rp))
|
||||
it = eina_file_ls(path);
|
||||
if (!it) return;
|
||||
EINA_ITERATOR_FOREACH(it, ent)
|
||||
{
|
||||
Eina_Iterator *it;
|
||||
const char *ent;
|
||||
|
||||
it = eina_file_ls(rp);
|
||||
if (!it) return;
|
||||
EINA_ITERATOR_FOREACH(it, ent)
|
||||
{
|
||||
rp = ent;
|
||||
// if (!realpath(ent, rp)) continue;
|
||||
if (!ecore_file_is_dir(rp)) continue;
|
||||
eina_hash_add(change_monitors, rp,
|
||||
ecore_file_monitor_add(rp,
|
||||
efreet_icon_changes_cb,
|
||||
NULL));
|
||||
}
|
||||
eina_iterator_free(it);
|
||||
if (!ecore_file_is_dir(ent)) continue;
|
||||
eina_hash_add(change_monitors, ent,
|
||||
ecore_file_monitor_add(ent,
|
||||
efreet_icon_changes_cb,
|
||||
NULL));
|
||||
}
|
||||
eina_iterator_free(it);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1537,34 +1537,26 @@ efreet_menu_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *pat
|
|||
{
|
||||
Efreet_Xml *merge_xml;
|
||||
Efreet_Menu_Internal *internal;
|
||||
// char rp[PATH_MAX];
|
||||
char *rp = path;
|
||||
|
||||
if (!parent || !xml || !path) return 0;
|
||||
|
||||
/* do nothing if the file doesn't exist */
|
||||
if (!ecore_file_exists(path)) return 1;
|
||||
|
||||
// if (!realpath(path, rp))
|
||||
// {
|
||||
// INF("efreet_menu_merge() unable to get real path for %s", path);
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
/* don't merge the same path twice */
|
||||
if (eina_hash_find(efreet_merged_menus, rp))
|
||||
if (eina_hash_find(efreet_merged_menus, path))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
eina_hash_add(efreet_merged_menus, rp, (void *)1);
|
||||
eina_hash_add(efreet_merged_menus, path, (void *)1);
|
||||
|
||||
merge_xml = efreet_xml_new(rp);
|
||||
merge_xml = efreet_xml_new(path);
|
||||
|
||||
if (!merge_xml)
|
||||
{
|
||||
INF("efreet_menu_merge() failed to read in the "
|
||||
"merge file (%s)", rp);
|
||||
"merge file (%s)", path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue