parent
bb71414d4d
commit
ad7cd0677e
325
src/bin/e_path.c
325
src/bin/e_path.c
|
@ -24,36 +24,36 @@ e_path_default_path_append(E_Path *ep, const char *path)
|
||||||
if (path[0] == '~')
|
if (path[0] == '~')
|
||||||
{
|
{
|
||||||
E_Path_Dir *epd;
|
E_Path_Dir *epd;
|
||||||
char *new_path;
|
char *new_path;
|
||||||
const char *home_dir;
|
const char *home_dir;
|
||||||
int len1, len2;
|
int len1, len2;
|
||||||
|
|
||||||
home_dir = e_user_homedir_get();
|
home_dir = e_user_homedir_get();
|
||||||
len1 = strlen(home_dir);
|
len1 = strlen(home_dir);
|
||||||
len2 = strlen(path);
|
len2 = strlen(path);
|
||||||
new_path = malloc(len1 + len2 + 1);
|
new_path = malloc(len1 + len2 + 1);
|
||||||
if (!new_path) return;
|
if (!new_path) return;
|
||||||
epd = malloc(sizeof(E_Path_Dir));
|
epd = malloc(sizeof(E_Path_Dir));
|
||||||
if (!epd)
|
if (!epd)
|
||||||
{
|
{
|
||||||
free(new_path);
|
free(new_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(new_path, home_dir);
|
strcpy(new_path, home_dir);
|
||||||
strcat(new_path, path + 1);
|
strcat(new_path, path + 1);
|
||||||
epd->dir = eina_stringshare_add(new_path);
|
epd->dir = eina_stringshare_add(new_path);
|
||||||
free(new_path);
|
free(new_path);
|
||||||
ep->default_dir_list = eina_list_append(ep->default_dir_list, epd);
|
ep->default_dir_list = eina_list_append(ep->default_dir_list, epd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
E_Path_Dir *epd;
|
E_Path_Dir *epd;
|
||||||
epd = malloc(sizeof(E_Path_Dir));
|
epd = malloc(sizeof(E_Path_Dir));
|
||||||
if (!epd)
|
if (!epd)
|
||||||
return;
|
return;
|
||||||
epd->dir = eina_stringshare_add(path);
|
epd->dir = eina_stringshare_add(path);
|
||||||
ep->default_dir_list = eina_list_append(ep->default_dir_list, epd);
|
ep->default_dir_list = eina_list_append(ep->default_dir_list, epd);
|
||||||
}
|
}
|
||||||
_e_path_cache_free(ep);
|
_e_path_cache_free(ep);
|
||||||
}
|
}
|
||||||
|
@ -77,36 +77,36 @@ e_path_user_path_append(E_Path *ep, const char *path)
|
||||||
if (path[0] == '~')
|
if (path[0] == '~')
|
||||||
{
|
{
|
||||||
E_Path_Dir *epd;
|
E_Path_Dir *epd;
|
||||||
char *new_path;
|
char *new_path;
|
||||||
const char *home_dir;
|
const char *home_dir;
|
||||||
int len1, len2;
|
int len1, len2;
|
||||||
|
|
||||||
home_dir = e_user_homedir_get();
|
home_dir = e_user_homedir_get();
|
||||||
len1 = strlen(home_dir);
|
len1 = strlen(home_dir);
|
||||||
len2 = strlen(path);
|
len2 = strlen(path);
|
||||||
new_path = malloc(len1 + len2 + 1);
|
new_path = malloc(len1 + len2 + 1);
|
||||||
if (!new_path) return;
|
if (!new_path) return;
|
||||||
epd = malloc(sizeof(E_Path_Dir));
|
epd = malloc(sizeof(E_Path_Dir));
|
||||||
if (!epd)
|
if (!epd)
|
||||||
{
|
{
|
||||||
free(new_path);
|
free(new_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(new_path, home_dir);
|
strcpy(new_path, home_dir);
|
||||||
strcat(new_path, path + 1);
|
strcat(new_path, path + 1);
|
||||||
epd->dir = eina_stringshare_add(new_path);
|
epd->dir = eina_stringshare_add(new_path);
|
||||||
free(new_path);
|
free(new_path);
|
||||||
*(ep->user_dir_list) = eina_list_append(*(ep->user_dir_list), epd);
|
*(ep->user_dir_list) = eina_list_append(*(ep->user_dir_list), epd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
E_Path_Dir *epd;
|
E_Path_Dir *epd;
|
||||||
epd = malloc(sizeof(E_Path_Dir));
|
epd = malloc(sizeof(E_Path_Dir));
|
||||||
if (!epd)
|
if (!epd)
|
||||||
return;
|
return;
|
||||||
epd->dir = eina_stringshare_add(path);
|
epd->dir = eina_stringshare_add(path);
|
||||||
*(ep->user_dir_list) = eina_list_append(*(ep->user_dir_list), epd);
|
*(ep->user_dir_list) = eina_list_append(*(ep->user_dir_list), epd);
|
||||||
}
|
}
|
||||||
_e_path_cache_free(ep);
|
_e_path_cache_free(ep);
|
||||||
}
|
}
|
||||||
|
@ -120,36 +120,36 @@ e_path_user_path_prepend(E_Path *ep, const char *path)
|
||||||
if (path[0] == '~')
|
if (path[0] == '~')
|
||||||
{
|
{
|
||||||
E_Path_Dir *epd;
|
E_Path_Dir *epd;
|
||||||
char *new_path;
|
char *new_path;
|
||||||
const char *home_dir;
|
const char *home_dir;
|
||||||
int len1, len2;
|
int len1, len2;
|
||||||
|
|
||||||
home_dir = e_user_homedir_get();
|
home_dir = e_user_homedir_get();
|
||||||
len1 = strlen(home_dir);
|
len1 = strlen(home_dir);
|
||||||
len2 = strlen(path);
|
len2 = strlen(path);
|
||||||
new_path = malloc(len1 + len2 + 1);
|
new_path = malloc(len1 + len2 + 1);
|
||||||
if (!new_path) return;
|
if (!new_path) return;
|
||||||
epd = malloc(sizeof(E_Path_Dir));
|
epd = malloc(sizeof(E_Path_Dir));
|
||||||
if (!epd)
|
if (!epd)
|
||||||
{
|
{
|
||||||
free(new_path);
|
free(new_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(new_path, home_dir);
|
strcpy(new_path, home_dir);
|
||||||
strcat(new_path, path + 1);
|
strcat(new_path, path + 1);
|
||||||
epd->dir = eina_stringshare_add(new_path);
|
epd->dir = eina_stringshare_add(new_path);
|
||||||
free(new_path);
|
free(new_path);
|
||||||
*(ep->user_dir_list) = eina_list_prepend(*(ep->user_dir_list), epd);
|
*(ep->user_dir_list) = eina_list_prepend(*(ep->user_dir_list), epd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
E_Path_Dir *epd;
|
E_Path_Dir *epd;
|
||||||
epd = malloc(sizeof(E_Path_Dir));
|
epd = malloc(sizeof(E_Path_Dir));
|
||||||
if (!epd)
|
if (!epd)
|
||||||
return;
|
return;
|
||||||
epd->dir = eina_stringshare_add(path);
|
epd->dir = eina_stringshare_add(path);
|
||||||
*(ep->user_dir_list) = eina_list_prepend(*(ep->user_dir_list), epd);
|
*(ep->user_dir_list) = eina_list_prepend(*(ep->user_dir_list), epd);
|
||||||
}
|
}
|
||||||
_e_path_cache_free(ep);
|
_e_path_cache_free(ep);
|
||||||
}
|
}
|
||||||
|
@ -165,52 +165,52 @@ e_path_user_path_remove(E_Path *ep, const char *path)
|
||||||
if (!path) return;
|
if (!path) return;
|
||||||
if (path[0] == '~')
|
if (path[0] == '~')
|
||||||
{
|
{
|
||||||
char *new_path;
|
char *new_path;
|
||||||
const char *home_dir;
|
const char *home_dir;
|
||||||
int len1, len2;
|
int len1, len2;
|
||||||
|
|
||||||
home_dir = e_user_homedir_get();
|
home_dir = e_user_homedir_get();
|
||||||
len1 = strlen(home_dir);
|
len1 = strlen(home_dir);
|
||||||
len2 = strlen(path);
|
len2 = strlen(path);
|
||||||
new_path = malloc(len1 + len2 + 1);
|
new_path = malloc(len1 + len2 + 1);
|
||||||
if (!new_path) return;
|
if (!new_path) return;
|
||||||
strcpy(new_path, home_dir);
|
strcpy(new_path, home_dir);
|
||||||
strcat(new_path, path + 1);
|
strcat(new_path, path + 1);
|
||||||
EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd)
|
EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd)
|
||||||
{
|
{
|
||||||
if (epd->dir)
|
if (epd->dir)
|
||||||
{
|
{
|
||||||
if (!strcmp(epd->dir, new_path))
|
if (!strcmp(epd->dir, new_path))
|
||||||
{
|
{
|
||||||
*(ep->user_dir_list) = eina_list_remove_list(
|
*(ep->user_dir_list) = eina_list_remove_list(
|
||||||
*(ep->user_dir_list), l);
|
*(ep->user_dir_list), l);
|
||||||
eina_stringshare_del(epd->dir);
|
eina_stringshare_del(epd->dir);
|
||||||
free(epd);
|
free(epd);
|
||||||
free(new_path);
|
free(new_path);
|
||||||
_e_path_cache_free(ep);
|
_e_path_cache_free(ep);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(new_path);
|
free(new_path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd)
|
EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd)
|
||||||
{
|
{
|
||||||
if (epd->dir)
|
if (epd->dir)
|
||||||
{
|
{
|
||||||
if (!strcmp(epd->dir, path))
|
if (!strcmp(epd->dir, path))
|
||||||
{
|
{
|
||||||
*(ep->user_dir_list) = eina_list_remove_list(
|
*(ep->user_dir_list) = eina_list_remove_list(
|
||||||
*(ep->user_dir_list), l);
|
*(ep->user_dir_list), l);
|
||||||
eina_stringshare_del(epd->dir);
|
eina_stringshare_del(epd->dir);
|
||||||
free(epd);
|
free(epd);
|
||||||
_e_path_cache_free(ep);
|
_e_path_cache_free(ep);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,8 +220,8 @@ e_path_user_path_clear(E_Path *ep)
|
||||||
E_Path_Dir *epd;
|
E_Path_Dir *epd;
|
||||||
EINA_LIST_FREE(*(ep->user_dir_list), epd)
|
EINA_LIST_FREE(*(ep->user_dir_list), epd)
|
||||||
{
|
{
|
||||||
eina_stringshare_del(epd->dir);
|
eina_stringshare_del(epd->dir);
|
||||||
free(epd);
|
free(epd);
|
||||||
}
|
}
|
||||||
_e_path_cache_free(ep);
|
_e_path_cache_free(ep);
|
||||||
}
|
}
|
||||||
|
@ -243,38 +243,38 @@ e_path_find(E_Path *ep, const char *file)
|
||||||
/* Look in the default dir list */
|
/* Look in the default dir list */
|
||||||
EINA_LIST_FOREACH(ep->default_dir_list, l, epd)
|
EINA_LIST_FOREACH(ep->default_dir_list, l, epd)
|
||||||
{
|
{
|
||||||
if (epd->dir)
|
if (epd->dir)
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file);
|
snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file);
|
||||||
if (ecore_file_exists(buf))
|
if (ecore_file_exists(buf))
|
||||||
{
|
{
|
||||||
if (!ep->hash)
|
if (!ep->hash)
|
||||||
ep->hash = eina_hash_string_superfast_new(NULL);
|
ep->hash = eina_hash_string_superfast_new(NULL);
|
||||||
if (eina_hash_population(ep->hash) >= 512)
|
if (eina_hash_population(ep->hash) >= 512)
|
||||||
_e_path_cache_free(ep);
|
_e_path_cache_free(ep);
|
||||||
eina_hash_add(ep->hash, file,
|
eina_hash_add(ep->hash, file,
|
||||||
eina_stringshare_add(buf));
|
eina_stringshare_add(buf));
|
||||||
return eina_stringshare_add(buf);
|
return eina_stringshare_add(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Look in the users dir list */
|
/* Look in the users dir list */
|
||||||
EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd)
|
EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd)
|
||||||
{
|
{
|
||||||
if (epd->dir)
|
if (epd->dir)
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file);
|
snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file);
|
||||||
if (ecore_file_exists(buf))
|
if (ecore_file_exists(buf))
|
||||||
{
|
{
|
||||||
if (!ep->hash)
|
if (!ep->hash)
|
||||||
ep->hash = eina_hash_string_superfast_new(NULL);
|
ep->hash = eina_hash_string_superfast_new(NULL);
|
||||||
if (eina_hash_population(ep->hash) >= 512)
|
if (eina_hash_population(ep->hash) >= 512)
|
||||||
_e_path_cache_free(ep);
|
_e_path_cache_free(ep);
|
||||||
eina_hash_add(ep->hash, file,
|
eina_hash_add(ep->hash, file,
|
||||||
eina_stringshare_add(buf));
|
eina_stringshare_add(buf));
|
||||||
return eina_stringshare_add(buf);
|
return eina_stringshare_add(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -293,9 +293,9 @@ e_path_evas_append(E_Path *ep, Evas *evas)
|
||||||
|
|
||||||
EINA_LIST_FREE(dir_list, epd)
|
EINA_LIST_FREE(dir_list, epd)
|
||||||
{
|
{
|
||||||
if (epd->dir) evas_font_path_append(evas, epd->dir);
|
if (epd->dir) evas_font_path_append(evas, epd->dir);
|
||||||
eina_stringshare_del(epd->dir);
|
eina_stringshare_del(epd->dir);
|
||||||
free(epd);
|
free(epd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,28 +303,28 @@ e_path_evas_append(E_Path *ep, Evas *evas)
|
||||||
EAPI Eina_List *
|
EAPI Eina_List *
|
||||||
e_path_dir_list_get(E_Path *ep)
|
e_path_dir_list_get(E_Path *ep)
|
||||||
{
|
{
|
||||||
Eina_List *dir_list;
|
Eina_List *dir_list;
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
E_Path_Dir *new_epd;
|
E_Path_Dir *new_epd;
|
||||||
E_Path_Dir *epd;
|
E_Path_Dir *epd;
|
||||||
|
|
||||||
dir_list = NULL;
|
dir_list = NULL;
|
||||||
|
|
||||||
if (ep->user_dir_list)
|
if (ep->user_dir_list)
|
||||||
{
|
{
|
||||||
EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd)
|
EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd)
|
||||||
{
|
{
|
||||||
new_epd = malloc(sizeof(E_Path_Dir));
|
new_epd = malloc(sizeof(E_Path_Dir));
|
||||||
new_epd->dir = eina_stringshare_add(epd->dir);
|
new_epd->dir = eina_stringshare_add(epd->dir);
|
||||||
dir_list = eina_list_append(dir_list, new_epd);
|
dir_list = eina_list_append(dir_list, new_epd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EINA_LIST_FOREACH(ep->default_dir_list, l, epd)
|
EINA_LIST_FOREACH(ep->default_dir_list, l, epd)
|
||||||
{
|
{
|
||||||
new_epd = malloc(sizeof(E_Path_Dir));
|
new_epd = malloc(sizeof(E_Path_Dir));
|
||||||
new_epd->dir = eina_stringshare_add(epd->dir);
|
new_epd->dir = eina_stringshare_add(epd->dir);
|
||||||
dir_list = eina_list_append(dir_list, new_epd);
|
dir_list = eina_list_append(dir_list, new_epd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dir_list;
|
return dir_list;
|
||||||
|
@ -337,8 +337,8 @@ e_path_dir_list_free(Eina_List *dir_list)
|
||||||
|
|
||||||
EINA_LIST_FREE(dir_list, epd)
|
EINA_LIST_FREE(dir_list, epd)
|
||||||
{
|
{
|
||||||
eina_stringshare_del(epd->dir);
|
eina_stringshare_del(epd->dir);
|
||||||
free(epd);
|
free(epd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,8 +351,8 @@ _e_path_free(E_Path *ep)
|
||||||
_e_path_cache_free(ep);
|
_e_path_cache_free(ep);
|
||||||
EINA_LIST_FREE(ep->default_dir_list, epd)
|
EINA_LIST_FREE(ep->default_dir_list, epd)
|
||||||
{
|
{
|
||||||
eina_stringshare_del(epd->dir);
|
eina_stringshare_del(epd->dir);
|
||||||
free(epd);
|
free(epd);
|
||||||
}
|
}
|
||||||
free(ep);
|
free(ep);
|
||||||
}
|
}
|
||||||
|
@ -372,3 +372,4 @@ _e_path_cache_free_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED
|
||||||
eina_stringshare_del(data);
|
eina_stringshare_del(data);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue