Changed do_reload_dir() function

...to handle vfs_path_t objects.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2011-10-03 17:19:05 +03:00
parent e7dc7ebf2d
commit 98bad221f8
3 changed files with 13 additions and 15 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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)