* dir.c (do_load_dir): Add new argument "path" to avoid the need

to request the current directory.
(do_reload_dir): Likewise.  Adjust all callers.
This commit is contained in:
Pavel Roskin 2003-06-06 00:52:35 +00:00
parent ab84c14503
commit 61ac4d5ca1
5 changed files with 56 additions and 50 deletions

View File

@ -1,5 +1,9 @@
2003-06-05 Pavel Roskin <proski@gnu.org>
* dir.c (do_load_dir): Add new argument "path" to avoid the need
to request the current directory.
(do_reload_dir): Likewise. Adjust all callers.
* screen.c (panel_destroy): Rewind history to the beginning
before freeing it.
* widget.c (input_destroy): Likewise.

View File

@ -462,8 +462,8 @@ handle_path (dir_list *list, char *path,
}
int
do_load_dir (dir_list *list, sortfn *sort, int reverse, int case_sensitive,
char *filter)
do_load_dir (char *path, dir_list *list, sortfn *sort, int reverse,
int case_sensitive, char *filter)
{
DIR *dirp;
struct dirent *dp;
@ -504,7 +504,7 @@ do_load_dir (dir_list *list, sortfn *sort, int reverse, int case_sensitive,
if (next_free) {
/* Add ".." except the root directory */
if (strcmp (vfs_canon ("."), "/") != 0)
if (strcmp (path, "/") != 0)
add_dotdot_to_list (list, next_free++);
do_sort (list, sort, next_free - 1, reverse, case_sensitive);
} else {
@ -567,8 +567,8 @@ alloc_dir_copy (int size)
/* If filter is null, then it is a match */
int
do_reload_dir (dir_list * list, sortfn * sort, int count, int rev,
int case_sensitive, char *filter)
do_reload_dir (char *path, dir_list *list, sortfn *sort, int count,
int rev, int case_sensitive, char *filter)
{
DIR *dirp;
struct dirent *dp;
@ -656,7 +656,7 @@ do_reload_dir (dir_list * list, sortfn * sort, int count, int rev,
g_hash_table_destroy (marked_files);
if (next_free) {
/* Add ".." except the root directory */
if (strcmp (vfs_canon ("."), "/") != 0)
if (strcmp (path, "/") != 0)
add_dotdot_to_list (list, next_free++);
do_sort (list, sort, next_free - 1, rev, case_sensitive);
} else

View File

@ -29,15 +29,15 @@ typedef struct {
typedef int sortfn (const void *, const void *);
int do_load_dir (dir_list *list, sortfn *sort,
int reverse, int case_sensitive, char *filter);
void do_sort (dir_list *list, sortfn *sort, int top,
int reverse, int case_sensitive);
dir_list *do_collect_stat (dir_list *dir, int top);
int do_reload_dir (dir_list *list, sortfn *sort, int count,
int reverse, int case_sensitive, char *filter);
void clean_dir (dir_list *list, int count);
int set_zero_dir (dir_list *list);
int do_load_dir (char *path, dir_list * list, sortfn * sort, int reverse,
int case_sensitive, char *filter);
void do_sort (dir_list * list, sortfn * sort, int top, int reverse,
int case_sensitive);
dir_list *do_collect_stat (dir_list * dir, int top);
int do_reload_dir (char *path, dir_list * list, sortfn * sort, int count,
int reverse, int case_sensitive, char *filter);
void clean_dir (dir_list * list, int count);
int set_zero_dir (dir_list * list);
#ifdef DIR_H_INCLUDE_HANDLE_DIRENT
int handle_dirent (dir_list *list, char *filter, struct dirent *dp,

View File

@ -772,8 +772,8 @@ _do_panel_cd (WPanel *panel, char *new_dir, enum cd_enum cd_type)
/* Reload current panel */
panel_clean_dir (panel);
panel->count =
do_load_dir (&panel->dir, panel->sort_type, panel->reverse,
panel->case_sensitive, panel->filter);
do_load_dir (panel->cwd, &panel->dir, panel->sort_type,
panel->reverse, panel->case_sensitive, panel->filter);
try_to_select (panel, get_parent_dir_name (panel->cwd, olddir));
load_hint (0);
panel_update_contents (panel);

View File

@ -942,41 +942,41 @@ panel_new (const char *panel_name)
/* We do not want the cursor */
widget_want_cursor (panel->widget, 0);
mc_get_current_wd (panel->cwd, sizeof (panel->cwd)-2);
mc_get_current_wd (panel->cwd, sizeof (panel->cwd) - 2);
strcpy (panel->lwd, ".");
panel->hist_name = g_strconcat ("Dir Hist ", panel_name, NULL);
panel->dir_history = history_get (panel->hist_name);
directory_history_add (panel, panel->cwd);
panel->dir.list = g_new (file_entry, MIN_FILES);
panel->dir.size = MIN_FILES;
panel->active = 0;
panel->filter = 0;
panel->split = 0;
panel->top_file = 0;
panel->selected = 0;
panel->marked = 0;
panel->total = 0;
panel->reverse = 0;
panel->dirty = 1;
panel->searching = 0;
panel->dirs_marked = 0;
panel->is_panelized = 0;
panel->format = 0;
panel->status_format = 0;
panel->format_modified = 1;
panel->dir.list = g_new (file_entry, MIN_FILES);
panel->dir.size = MIN_FILES;
panel->active = 0;
panel->filter = 0;
panel->split = 0;
panel->top_file = 0;
panel->selected = 0;
panel->marked = 0;
panel->total = 0;
panel->reverse = 0;
panel->dirty = 1;
panel->searching = 0;
panel->dirs_marked = 0;
panel->is_panelized = 0;
panel->format = 0;
panel->status_format = 0;
panel->format_modified = 1;
panel->panel_name = g_strdup (panel_name);
panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
for(i = 0; i < LIST_TYPES; i++)
panel->user_status_format [i] = g_strdup (DEFAULT_USER_FORMAT);
for (i = 0; i < LIST_TYPES; i++)
panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
panel->search_buffer [0] = 0;
panel->search_buffer[0] = 0;
panel->frame_size = frame_half;
section = g_strconcat ("Temporal:", panel->panel_name, NULL);
if (!profile_has_section (section, profile_name)){
if (!profile_has_section (section, profile_name)) {
g_free (section);
section = g_strdup (panel->panel_name);
}
@ -985,13 +985,14 @@ panel_new (const char *panel_name)
/* Load format strings */
err = set_panel_formats (panel);
if (err){
if (err) {
set_panel_formats (panel);
}
/* Load the default format */
panel->count = do_load_dir (&panel->dir, panel->sort_type,
panel->reverse, panel->case_sensitive, panel->filter);
panel->count =
do_load_dir (panel->cwd, &panel->dir, panel->sort_type,
panel->reverse, panel->case_sensitive, panel->filter);
return panel;
}
@ -1000,16 +1001,15 @@ panel_reload (WPanel *panel)
{
struct stat current_stat;
if (fast_reload
&& !stat (panel->cwd, &current_stat)
if (fast_reload && !stat (panel->cwd, &current_stat)
&& current_stat.st_ctime == panel->dir_stat.st_ctime
&& current_stat.st_mtime == panel->dir_stat.st_mtime)
return;
while (mc_chdir (panel->cwd) == -1){
while (mc_chdir (panel->cwd) == -1) {
char *last_slash;
if (panel->cwd [0] == PATH_SEP && panel->cwd [1] == 0){
if (panel->cwd[0] == PATH_SEP && panel->cwd[1] == 0) {
panel_clean_dir (panel);
panel->count = set_zero_dir (&panel->dir);
return;
@ -1019,16 +1019,18 @@ panel_reload (WPanel *panel)
strcpy (panel->cwd, PATH_SEP_STR);
else
*last_slash = 0;
memset (&(panel->dir_stat), 0, sizeof (panel->dir_stat));
memset (&(panel->dir_stat), 0, sizeof (panel->dir_stat));
show_dir (panel);
}
panel->count = do_reload_dir (&panel->dir, panel->sort_type, panel->count,
panel->reverse, panel->case_sensitive, panel->filter);
panel->count =
do_reload_dir (panel->cwd, &panel->dir, panel->sort_type,
panel->count, panel->reverse, panel->case_sensitive,
panel->filter);
panel->dirty = 1;
if (panel->selected >= panel->count)
do_select (panel, panel->count-1);
do_select (panel, panel->count - 1);
recalculate_panel_summary (panel);
}