edje - handle errors and eina file handles and vpath properly

@fix
This commit is contained in:
Carsten Haitzler 2019-08-20 15:15:28 +01:00
parent 92dbf3dc83
commit bc90cbfdff
1 changed files with 15 additions and 8 deletions

View File

@ -262,16 +262,18 @@ EAPI Eina_List *
edje_file_collection_list(const char *file) edje_file_collection_list(const char *file)
{ {
Eina_File *f; Eina_File *f;
Eina_List *lst; Eina_List *lst = NULL;
char *tmp; char *tmp;
if ((!file) || (!*file)) return NULL; if ((!file) || (!*file)) return NULL;
tmp = eina_vpath_resolve(file); tmp = eina_vpath_resolve(file);
f = eina_file_open(tmp, EINA_FALSE); f = eina_file_open(tmp, EINA_FALSE);
if (!f) goto err;
lst = edje_mmap_collection_list(f); lst = edje_mmap_collection_list(f);
eina_file_close(f); eina_file_close(f);
err:
free(tmp); free(tmp);
return lst; return lst;
} }
@ -433,17 +435,21 @@ EAPI Eina_Bool
edje_file_group_exists(const char *file, const char *glob) edje_file_group_exists(const char *file, const char *glob)
{ {
Eina_File *f; Eina_File *f;
Eina_Bool result; Eina_Bool result = EINA_FALSE;
char *tmp;
if ((!file) || (!*file) || (!glob)) if ((!file) || (!*file) || (!glob))
return EINA_FALSE; return EINA_FALSE;
f = eina_file_open(file, EINA_FALSE); tmp = eina_vpath_resolve(file);
if (!f) return EINA_FALSE; f = eina_file_open(tmp, EINA_FALSE);
if (!f) goto err;
result = edje_mmap_group_exists(f, glob); result = edje_mmap_group_exists(f, glob);
eina_file_close(f); eina_file_close(f);
err:
free(tmp);
return result; return result;
} }
@ -473,20 +479,21 @@ EAPI char *
edje_file_data_get(const char *file, const char *key) edje_file_data_get(const char *file, const char *key)
{ {
Eina_File *f; Eina_File *f;
char *str; char *str = NULL, *tmp;
if (!key) return NULL; if (!key) return NULL;
tmp = eina_vpath_resolve(file);
f = eina_file_open(file, EINA_FALSE); f = eina_file_open(file, EINA_FALSE);
if (!f) if (!f)
{ {
ERR("File [%s] can not be opened.", file); ERR("File [%s] can not be opened.", file);
return NULL; goto err;
} }
str = edje_mmap_data_get(f, key); str = edje_mmap_data_get(f, key);
eina_file_close(f); eina_file_close(f);
err:
free(tmp);
return str; return str;
} }