1
1

Changed do_reload_dir() function

...to handle vfs_path_t objects.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
Slava Zanko 2011-10-03 17:19:05 +03:00
родитель e7dc7ebf2d
Коммит 98bad221f8
3 изменённых файлов: 13 добавлений и 15 удалений

Просмотреть файл

@ -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 */ /** If fltr is null, then it is a match */
int 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) gboolean lc_reverse, gboolean lc_case_sensitive, gboolean exec_ff, const char *fltr)
{ {
DIR *dirp; DIR *dirp;
@ -627,19 +627,19 @@ do_reload_dir (const char *path, dir_list * list, sortfn * sort, int count,
struct stat st; struct stat st;
int marked_cnt; int marked_cnt;
GHashTable *marked_files; GHashTable *marked_files;
vfs_path_t *vpath; char *tmp_path;
vpath = vfs_path_from_str (path);
dirp = mc_opendir (vpath); dirp = mc_opendir (vpath);
if (dirp == NULL) if (dirp == NULL)
{ {
message (D_ERROR, MSG_ERROR, _("Cannot read directory contents")); message (D_ERROR, MSG_ERROR, _("Cannot read directory contents"));
clean_dir (list, count); clean_dir (list, count);
vfs_path_free (vpath);
return set_zero_dir (list) ? 1 : 0; 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); marked_files = g_hash_table_new (g_str_hash, g_str_equal);
alloc_dir_copy (list->size); alloc_dir_copy (list->size);
for (marked_cnt = i = 0; i < count; i++) 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 /* Add ".." except to the root directory. The ".." entry
(if any) must be the first in the list. */ (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)) if (!set_zero_dir (list))
{ {
clean_dir (list, count); clean_dir (list, count);
clean_dir (&dir_copy, 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; list->list[next_free].st = st;
next_free++; next_free++;
} }
g_free (tmp_path);
while ((dp = mc_readdir (dirp))) 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 (); tree_store_end_check ();
g_hash_table_destroy (marked_files); g_hash_table_destroy (marked_files);
goto ret; return next_free;
} }
list->list[next_free].f.marked = 0; 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); do_sort (list, sort, next_free - 1, lc_reverse, lc_case_sensitive, exec_ff);
} }
clean_dir (&dir_copy, count); clean_dir (&dir_copy, count);
ret:
vfs_path_free (vpath);
return next_free; return next_free;
} }

Просмотреть файл

@ -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); gboolean case_sensitive, gboolean exec_ff, const char *fltr);
void do_sort (dir_list * list, sortfn * sort, int top, gboolean reverse, void do_sort (dir_list * list, sortfn * sort, int top, gboolean reverse,
gboolean case_sensitive, gboolean exec_ff); 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); gboolean reverse, gboolean case_sensitive, gboolean exec_ff, const char *fltr);
void clean_dir (dir_list * list, int count); void clean_dir (dir_list * list, int count);
gboolean set_zero_dir (dir_list * list); gboolean set_zero_dir (dir_list * list);

Просмотреть файл

@ -4129,12 +4129,10 @@ panel_reload (WPanel * panel)
} }
while (TRUE); while (TRUE);
tmp_path = vfs_path_to_str (panel->cwd_vpath);
panel->count = 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->count, panel->sort_info.reverse, panel->sort_info.case_sensitive,
panel->sort_info.exec_first, panel->filter); panel->sort_info.exec_first, panel->filter);
g_free (tmp_path);
panel->dirty = 1; panel->dirty = 1;
if (panel->selected >= panel->count) if (panel->selected >= panel->count)