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