diff --git a/src/filemanager/dir.c b/src/filemanager/dir.c index b63c5c48e..6b50fd8b8 100644 --- a/src/filemanager/dir.c +++ b/src/filemanager/dir.c @@ -617,7 +617,7 @@ if_link_is_exe (const char *full_name, const file_entry * file) /** If fltr is null, then it is a match */ int -do_reload_dir (const char *path, dir_list * list, sortfn * sort, int count, +do_reload_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, int count, gboolean lc_reverse, gboolean lc_case_sensitive, gboolean exec_ff, const char *fltr) { DIR *dirp; @@ -627,19 +627,19 @@ do_reload_dir (const char *path, dir_list * list, sortfn * sort, int count, struct stat st; int marked_cnt; GHashTable *marked_files; - vfs_path_t *vpath; + char *tmp_path; - vpath = vfs_path_from_str (path); dirp = mc_opendir (vpath); if (dirp == NULL) { message (D_ERROR, MSG_ERROR, _("Cannot read directory contents")); clean_dir (list, count); - vfs_path_free (vpath); return set_zero_dir (list) ? 1 : 0; } - tree_store_start_check (path); + tmp_path = vfs_path_to_str (vpath); + tree_store_start_check (tmp_path); + marked_files = g_hash_table_new (g_str_hash, g_str_equal); alloc_dir_copy (list->size); for (marked_cnt = i = 0; i < count; i++) @@ -661,20 +661,22 @@ do_reload_dir (const char *path, dir_list * list, sortfn * sort, int count, /* Add ".." except to the root directory. The ".." entry (if any) must be the first in the list. */ - if (!((path[0] == PATH_SEP) && (path[1] == '\0'))) + if (!((tmp_path[0] == PATH_SEP) && (tmp_path[1] == '\0'))) { if (!set_zero_dir (list)) { clean_dir (list, count); clean_dir (&dir_copy, count); - goto ret; + g_free (tmp_path); + return next_free; } - if (get_dotdot_dir_stat (path, &st)) + if (get_dotdot_dir_stat (tmp_path, &st)) list->list[next_free].st = st; next_free++; } + g_free (tmp_path); while ((dp = mc_readdir (dirp))) { @@ -696,7 +698,7 @@ do_reload_dir (const char *path, dir_list * list, sortfn * sort, int count, */ tree_store_end_check (); g_hash_table_destroy (marked_files); - goto ret; + return next_free; } list->list[next_free].f.marked = 0; @@ -735,8 +737,6 @@ do_reload_dir (const char *path, dir_list * list, sortfn * sort, int count, do_sort (list, sort, next_free - 1, lc_reverse, lc_case_sensitive, exec_ff); } clean_dir (&dir_copy, count); - ret: - vfs_path_free (vpath); return next_free; } diff --git a/src/filemanager/dir.h b/src/filemanager/dir.h index dd135421f..9acc5dbd0 100644 --- a/src/filemanager/dir.h +++ b/src/filemanager/dir.h @@ -35,7 +35,7 @@ int do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean reve gboolean case_sensitive, gboolean exec_ff, const char *fltr); void do_sort (dir_list * list, sortfn * sort, int top, gboolean reverse, gboolean case_sensitive, gboolean exec_ff); -int do_reload_dir (const char *path, dir_list * list, sortfn * sort, int count, +int do_reload_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, int count, gboolean reverse, gboolean case_sensitive, gboolean exec_ff, const char *fltr); void clean_dir (dir_list * list, int count); gboolean set_zero_dir (dir_list * list); diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index b1faa2d4a..a5630bbc9 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -4129,12 +4129,10 @@ panel_reload (WPanel * panel) } while (TRUE); - tmp_path = vfs_path_to_str (panel->cwd_vpath); panel->count = - do_reload_dir (tmp_path, &panel->dir, panel->sort_info.sort_field->sort_routine, + do_reload_dir (panel->cwd_vpath, &panel->dir, panel->sort_info.sort_field->sort_routine, panel->count, panel->sort_info.reverse, panel->sort_info.case_sensitive, panel->sort_info.exec_first, panel->filter); - g_free (tmp_path); panel->dirty = 1; if (panel->selected >= panel->count)