(do_load_dir): use vfs_path_t as a path handle.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-04-19 13:19:47 +04:00
parent adbfbf40df
commit 7d5261a1dc
4 changed files with 16 additions and 26 deletions

View File

@ -533,7 +533,7 @@ handle_path (dir_list * list, const char *path,
/* --------------------------------------------------------------------------------------------- */
int
do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean lc_reverse,
do_load_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, gboolean lc_reverse,
gboolean lc_case_sensitive, gboolean exec_ff, const char *fltr)
{
DIR *dirp;
@ -541,13 +541,11 @@ do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean lc_rever
int status, link_to_dir, stale_link;
int next_free = 0;
struct stat st;
vfs_path_t *vpath;
/* ".." (if any) must be the first entry in the list */
if (!set_zero_dir (list))
return next_free;
vpath = vfs_path_from_str (path);
if (get_dotdot_dir_stat (vpath, &st))
list->list[next_free].st = st;
next_free++;
@ -556,7 +554,7 @@ do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean lc_rever
if (dirp == NULL)
{
message (D_ERROR, MSG_ERROR, _("Cannot read directory contents"));
goto ret;
return next_free;
}
tree_store_start_check (vpath);
@ -565,17 +563,14 @@ do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean lc_rever
if ((path[0] == PATH_SEP) && (path[1] == '\0'))
next_free--;
while ((dp = mc_readdir (dirp)))
while ((dp = mc_readdir (dirp)) != NULL)
{
status = handle_dirent (list, fltr, dp, &st, next_free, &link_to_dir, &stale_link);
if (status == 0)
continue;
if (status == -1)
{
tree_store_end_check ();
mc_closedir (dirp);
goto ret;
}
list->list[next_free].fnamelen = NLENGTH (dp);
list->list[next_free].fname = g_strndup (dp->d_name, list->list[next_free].fnamelen);
list->list[next_free].f.marked = 0;
@ -594,10 +589,9 @@ do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean lc_rever
if (next_free != 0)
do_sort (list, sort, next_free - 1, lc_reverse, lc_case_sensitive, exec_ff);
ret:
mc_closedir (dirp);
tree_store_end_check ();
ret:
vfs_path_free (vpath);
return next_free;
}

View File

@ -32,7 +32,7 @@ typedef struct
/*** declarations of public functions ************************************************************/
int do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean reverse,
int do_load_dir (const vfs_path_t * vpath, dir_list * list, sortfn * sort, gboolean reverse,
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);

View File

@ -2916,17 +2916,19 @@ _do_panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_
/* Reload current panel */
panel_clean_dir (panel);
{
char *tmp_path;
tmp_path = vfs_path_to_str (panel->cwd_vpath);
panel->count =
do_load_dir (tmp_path, &panel->dir, panel->sort_info.sort_field->sort_routine,
do_load_dir (panel->cwd_vpath, &panel->dir, panel->sort_info.sort_field->sort_routine,
panel->sort_info.reverse, panel->sort_info.case_sensitive,
panel->sort_info.exec_first, panel->filter);
tmp_path = vfs_path_to_str (panel->cwd_vpath);
try_to_select (panel, get_parent_dir_name (tmp_path, olddir));
g_free (tmp_path);
}
load_hint (0);
panel->dirty = 1;
update_xterm_title_path ();
@ -3981,16 +3983,10 @@ panel_new_with_dir (const char *panel_name, const char *wpath)
}
/* Load the default format */
{
char *tmp_path;
tmp_path = vfs_path_to_str (panel->cwd_vpath);
panel->count =
do_load_dir (tmp_path, &panel->dir, panel->sort_info.sort_field->sort_routine,
do_load_dir (panel->cwd_vpath, &panel->dir, panel->sort_info.sort_field->sort_routine,
panel->sort_info.reverse, panel->sort_info.case_sensitive,
panel->sort_info.exec_first, panel->filter);
g_free (tmp_path);
}
/* Restore old right path */
if (curdir != NULL)

View File

@ -136,10 +136,10 @@ get_panel_widget (int idx)
int
do_load_dir (const char *path, dir_list * list, sortfn * sort, gboolean reverse,
do_load_dir (const vfs_path_t *vpath, dir_list * list, sortfn * sort, gboolean reverse,
gboolean case_sensitive, gboolean exec_ff, const char *fltr)
{
(void) path;
(void) vpath;
(void) list;
(void) sort;
(void) reverse;