sanitize compare file pathes.

let's have a full pathes for enventor items.
then we don't need to call ecore_file_realpath() at every accesses.
This commit is contained in:
Hermet Park 2016-08-09 01:02:46 +09:00
parent e086a6edbb
commit a281963ba1
3 changed files with 14 additions and 25 deletions

View File

@ -263,7 +263,17 @@ file_mgr_main_file_set(const char *path)
return NULL;
}
char *realpath = ecore_file_realpath(path);
char *realpath;
if (ecore_file_exists(path))
realpath = ecore_file_realpath(path);
else
{
//This main file is not created yet.
FILE *fp = fopen(path, "w");
if (fp) fclose(fp);
realpath = ecore_file_realpath(path);
}
//Same with previous?
Enventor_Item *main_it = file_mgr_main_item_get();
@ -418,17 +428,11 @@ file_mgr_file_open(const char *file_path)
return EINA_FALSE;
}
//Ok, This selected file is already openend, let's activate the item.
char *txt1 = ecore_file_realpath(file_path);
char *txt2 = ecore_file_realpath(it_file_path);
if (!strcmp(txt1, txt2))
if (!strcmp(file_path, it_file_path))
{
file_mgr_file_focus(eit);
free(txt1);
free(txt2);
return EINA_TRUE;
}
free(txt1);
free(txt2);
}
//Case 2. sub files.
@ -441,17 +445,11 @@ file_mgr_file_open(const char *file_path)
if (!it_file_path) continue;
//Ok, This selected file is already openend, let's activate the item.
char *txt1 = ecore_file_realpath(file_path);
char *txt2 = ecore_file_realpath(it_file_path);
if (!strcmp(txt1, txt2))
if (!strcmp(file_path, it_file_path))
{
file_mgr_file_focus(eit);
free(txt1);
free(txt2);
return EINA_TRUE;
}
free(txt1);
free(txt2);
}
//This selected file hasn't been opened yet, so let's open this file newly.

View File

@ -219,9 +219,7 @@ file_tab_it_add(Enventor_Item *enventor_it)
fti->it = elm_list_item_append(fd->list, filename, btn, NULL,
list_item_selected_cb, fti);
char *txt = ecore_file_realpath(filepath);
elm_object_item_tooltip_text_set(fti->it, txt);
free(txt);
elm_object_item_tooltip_text_set(fti->it, filepath);
elm_list_go(fd->list);

View File

@ -391,13 +391,6 @@ _enventor_object_efl_file_file_set(Eo *obj EINA_UNUSED,
build_edc_path_set(file);
if (!file) goto err;
/* Create empty file*/
if (!ecore_file_exists(file))
{
FILE *fp = fopen(file, "w");
if (fp) fclose(fp);
}
if (!edit_load(pd->main_it->ed, file)) return EINA_FALSE;
build_edc();
edit_changed_set(pd->main_it->ed, EINA_FALSE);