From 92cdd898879b552577f985babd4403e7e1ba0ddc Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 24 Aug 2013 10:17:58 +0400 Subject: [PATCH] Rename functions: set_zero_dir -> dir_list_init clean_dir -> dir_list_clean do_sort -> dir_list_sort do_load_dir -> dir_list_load do_reload_dir -> dir_list_reload get_dotdot_dir_stat -> dir_get_dotdot_stat Signed-off-by: Andrew Borodin --- src/filemanager/dir.c | 44 ++++++++++++++++++-------------------- src/filemanager/dir.h | 12 +++++------ src/filemanager/find.c | 2 +- src/filemanager/midnight.c | 4 ++-- src/filemanager/panel.c | 22 +++++++++---------- src/filemanager/panelize.c | 10 ++++----- src/viewer/actions_cmd.c | 2 +- src/viewer/lib.c | 2 +- 8 files changed, 48 insertions(+), 50 deletions(-) diff --git a/src/filemanager/dir.c b/src/filemanager/dir.c index 4c04ac882..87e1bd357 100644 --- a/src/filemanager/dir.c +++ b/src/filemanager/dir.c @@ -193,7 +193,7 @@ handle_dirent (struct dirent *dp, const char *fltr, struct stat *buf1, int *link /** get info about ".." */ static gboolean -get_dotdot_dir_stat (const vfs_path_t * vpath, struct stat *st) +dir_get_dotdot_stat (const vfs_path_t * vpath, struct stat *st) { gboolean ret = FALSE; @@ -205,12 +205,10 @@ get_dotdot_dir_stat (const vfs_path_t * vpath, struct stat *st) if (path != NULL && *path != '\0') { vfs_path_t *tmp_vpath; - struct stat s; tmp_vpath = vfs_path_append_new (vpath, "..", NULL); - ret = mc_stat (tmp_vpath, &s) == 0; + ret = mc_stat (tmp_vpath, st) == 0; vfs_path_free (tmp_vpath); - *st = s; } } @@ -493,7 +491,7 @@ sort_size (file_entry * a, file_entry * b) /* --------------------------------------------------------------------------------------------- */ void -do_sort (dir_list * list, GCompareFunc sort, const dir_sort_options_t * sort_op) +dir_list_sort (dir_list * list, GCompareFunc sort, const dir_sort_options_t * sort_op) { int dot_dot_found = 0; @@ -516,7 +514,7 @@ do_sort (dir_list * list, GCompareFunc sort, const dir_sort_options_t * sort_op) /* --------------------------------------------------------------------------------------------- */ void -clean_dir (dir_list * list) +dir_list_clean (dir_list * list) { int i; @@ -535,7 +533,7 @@ clean_dir (dir_list * list) /** Used to set up a directory list when there is no access to a directory */ gboolean -set_zero_dir (dir_list * list) +dir_list_init (dir_list * list) { /* Need to grow the *list? */ if (list->size == 0 && !dir_list_grow (list, DIR_LIST_RESIZE_STEP)) @@ -604,8 +602,8 @@ handle_path (const char *path, struct stat *buf1, int *link_to_dir, int *stale_l /* --------------------------------------------------------------------------------------------- */ void -do_load_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, - const dir_sort_options_t * sort_op, const char *fltr) +dir_list_load (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort, + const dir_sort_options_t * sort_op, const char *fltr) { DIR *dirp; struct dirent *dp; @@ -613,10 +611,10 @@ do_load_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, struct stat st; /* ".." (if any) must be the first entry in the list */ - if (!set_zero_dir (list)) + if (!dir_list_init (list)) return; - if (get_dotdot_dir_stat (vpath, &st)) + if (dir_get_dotdot_stat (vpath, &st)) list->list[0].st = st; dirp = mc_opendir (vpath); @@ -649,7 +647,7 @@ do_load_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, rotate_dash (TRUE); } - do_sort (list, sort, sort_op); + dir_list_sort (list, sort, sort_op); ret: mc_closedir (dirp); @@ -673,8 +671,8 @@ if_link_is_exe (const vfs_path_t * full_name_vpath, const file_entry * file) /** If fltr is null, then it is a match */ void -do_reload_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, - const dir_sort_options_t * sort_op, const char *fltr) +dir_list_reload (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort, + const dir_sort_options_t * sort_op, const char *fltr) { DIR *dirp; struct dirent *dp; @@ -688,8 +686,8 @@ do_reload_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, if (dirp == NULL) { message (D_ERROR, MSG_ERROR, _("Cannot read directory contents")); - clean_dir (list); - set_zero_dir (list); + dir_list_clean (list); + dir_list_init (list); return; } @@ -721,13 +719,13 @@ do_reload_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, (vfs_path_elements_count (vpath) == 1 && (tmp_path[0] == PATH_SEP) && (tmp_path[1] == '\0'))) { - if (!set_zero_dir (list)) + if (!dir_list_init (list)) { - clean_dir (&dir_copy); + dir_list_clean (&dir_copy); return; } - if (get_dotdot_dir_stat (vpath, &st)) + if (dir_get_dotdot_stat (vpath, &st)) list->list[0].st = st; } @@ -744,10 +742,10 @@ do_reload_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, -1 means big trouble (at the moment no memory left), I don't bother with further cleanup because if one gets to this point he will have more problems than a few memory - leaks and because one 'clean_dir' would not be enough (and + leaks and because one 'dir_list_clean' would not be enough (and because I don't want to spent the time to make it working, IMHO it's not worthwhile). - clean_dir (&dir_copy); + dir_list_clean (&dir_copy); */ tree_store_end_check (); g_hash_table_destroy (marked_files); @@ -774,9 +772,9 @@ do_reload_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, tree_store_end_check (); g_hash_table_destroy (marked_files); - do_sort (list, sort, sort_op); + dir_list_sort (list, sort, sort_op); - clean_dir (&dir_copy); + dir_list_clean (&dir_copy); rotate_dash (FALSE); } diff --git a/src/filemanager/dir.h b/src/filemanager/dir.h index b61982e18..e534eb109 100644 --- a/src/filemanager/dir.h +++ b/src/filemanager/dir.h @@ -48,13 +48,13 @@ gboolean dir_list_grow (dir_list * list, int delta); gboolean dir_list_append (dir_list * list, const char *fname, const struct stat *st, gboolean link_to_dir, gboolean stale_link); -void do_load_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, - const dir_sort_options_t * sort_op, const char *fltr); -void do_sort (dir_list * list, GCompareFunc sort, const dir_sort_options_t * sort_op); -void do_reload_dir (const vfs_path_t * vpath, dir_list * list, GCompareFunc sort, +void dir_list_load (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort, const dir_sort_options_t * sort_op, const char *fltr); -void clean_dir (dir_list * list); -gboolean set_zero_dir (dir_list * list); +void dir_list_reload (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort, + const dir_sort_options_t * sort_op, const char *fltr); +void dir_list_sort (dir_list * list, GCompareFunc sort, const dir_sort_options_t * sort_op); +gboolean dir_list_init (dir_list * list); +void dir_list_clean (dir_list * list); gboolean handle_path (const char *path, struct stat *buf1, int *link_to_dir, int *stale_link); /* Sorting functions */ diff --git a/src/filemanager/find.c b/src/filemanager/find.c index 5c3cfeebe..f9fce8d5c 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -1705,7 +1705,7 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, dir_list *list = ¤t_panel->dir; char *name = NULL; - set_zero_dir (list); + dir_list_init (list); for (i = 0, entry = find_list->list; entry != NULL; i++, entry = g_list_next (entry)) { diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index 6ef8ee80f..3dd8cd7dd 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -72,7 +72,7 @@ #include "hotlist.h" #include "panelize.h" #include "command.h" /* cmdline */ -#include "dir.h" /* clean_dir() */ +#include "dir.h" /* dir_list_clean() */ #include "chmod.h" #include "chown.h" @@ -1783,7 +1783,7 @@ do_nc (void) /* don't handle VFS timestamps for dirs opened in panels */ mc_event_destroy (MCEVENT_GROUP_CORE, "vfs_timestamp"); - clean_dir (&panelized_panel.list); + dir_list_clean (&panelized_panel.list); } /* Program end */ diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index e499c1092..344d71bd2 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -1008,7 +1008,7 @@ display_mini_info (WPanel * panel) else if (DIR_IS_DOTDOT (panel->dir.list[panel->selected].fname)) { /* FIXME: - * while loading directory (do_load_dir() and do_reload_dir()), + * while loading directory (dir_list_load() and dir_list_reload()), * the actual stat info about ".." directory isn't got; * so just don't display incorrect info about ".." directory */ tty_print_string (str_fit_to_term (_("UP--DIR"), w->cols - 2, J_LEFT)); @@ -3063,8 +3063,8 @@ _do_panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_ /* Reload current panel */ panel_clean_dir (panel); - do_load_dir (panel->cwd_vpath, &panel->dir, panel->sort_field->sort_routine, &panel->sort_info, - panel->filter); + dir_list_load (&panel->dir, panel->cwd_vpath, panel->sort_field->sort_routine, &panel->sort_info, + panel->filter); try_to_select (panel, get_parent_dir_name (panel->cwd_vpath, olddir_vpath)); load_hint (0); @@ -3741,7 +3741,7 @@ reload_panelized (WPanel * panel) vfs_path_free (vpath); } if (j == 0) - set_zero_dir (list); + dir_list_init (list); else list->len = j; @@ -3975,7 +3975,7 @@ panel_clean_dir (WPanel * panel) panel->content_shift = -1; panel->max_shift = -1; - clean_dir (&panel->dir); + dir_list_clean (&panel->dir); } /* --------------------------------------------------------------------------------------------- */ @@ -4138,8 +4138,8 @@ panel_new_with_dir (const char *panel_name, const vfs_path_t * vpath) } /* Load the default format */ - do_load_dir (panel->cwd_vpath, &panel->dir, panel->sort_field->sort_routine, &panel->sort_info, - panel->filter); + dir_list_load (&panel->dir, panel->cwd_vpath, panel->sort_field->sort_routine, &panel->sort_info, + panel->filter); /* Restore old right path */ if (curdir != NULL) @@ -4175,7 +4175,7 @@ panel_reload (WPanel * panel) { panel->cwd_vpath = vfs_path_from_str (PATH_SEP_STR); panel_clean_dir (panel); - set_zero_dir (&panel->dir); + dir_list_init (&panel->dir); return; } @@ -4183,8 +4183,8 @@ panel_reload (WPanel * panel) memset (&(panel->dir_stat), 0, sizeof (panel->dir_stat)); show_dir (panel); - do_reload_dir (panel->cwd_vpath, &panel->dir, panel->sort_field->sort_routine, &panel->sort_info, - panel->filter); + dir_list_reload (&panel->dir, panel->cwd_vpath, panel->sort_field->sort_routine, + &panel->sort_info, panel->filter); panel->dirty = 1; if (panel->selected >= panel->dir.len) @@ -4439,7 +4439,7 @@ panel_re_sort (WPanel * panel) filename = g_strdup (selection (panel)->fname); unselect_item (panel); - do_sort (&panel->dir, panel->sort_field->sort_routine, &panel->sort_info); + dir_list_sort (&panel->dir, panel->sort_field->sort_routine, &panel->sort_info); panel->selected = -1; for (i = panel->dir.len; i != 0; i--) { diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c index d7df5804a..795558992 100644 --- a/src/filemanager/panelize.c +++ b/src/filemanager/panelize.c @@ -330,7 +330,7 @@ do_external_panelize (char *command) panelize_change_root (current_panel->cwd_vpath); - set_zero_dir (list); + dir_list_init (list); while (TRUE) { @@ -366,7 +366,7 @@ do_external_panelize (char *command) current_panel->is_panelized = TRUE; if (list->len == 0) - set_zero_dir (list); + dir_list_init (list); else if (list->list[0].fname[0] == PATH_SEP) { vfs_path_t *vpath_root; @@ -397,12 +397,12 @@ do_panelize_cd (struct WPanel *panel) dir_list *list; gboolean panelized_same; - clean_dir (&panel->dir); + dir_list_clean (&panel->dir); if (panelized_panel.root_vpath == NULL) panelize_change_root (current_panel->cwd_vpath); if (panelized_panel.list.len < 1) - set_zero_dir (&panelized_panel.list); + dir_list_init (&panelized_panel.list); else if (panelized_panel.list.len > panel->dir.size) dir_list_grow (&panel->dir, panelized_panel.list.len - panel->dir.size); @@ -470,7 +470,7 @@ panelize_save_panel (struct WPanel *panel) panelize_change_root (current_panel->cwd_vpath); if (panelized_panel.list.len > 0) - clean_dir (&panelized_panel.list); + dir_list_clean (&panelized_panel.list); if (panel->dir.len == 0) return; diff --git a/src/viewer/actions_cmd.c b/src/viewer/actions_cmd.c index beefd36e4..3f34989c8 100644 --- a/src/viewer/actions_cmd.c +++ b/src/viewer/actions_cmd.c @@ -304,7 +304,7 @@ mcview_load_next_prev_init (mcview_t * view) view->dir = g_new0 (dir_list, 1); view->dir_idx = g_new (int, 1); - do_load_dir (view->workdir_vpath, view->dir, (GCompareFunc) sort_name, &sort_op, NULL); + dir_list_load (view->dir, view->workdir_vpath, (GCompareFunc) sort_name, &sort_op, NULL); fname = x_basename (vfs_path_as_str (view->filename_vpath)); fname_len = strlen (fname); diff --git a/src/viewer/lib.c b/src/viewer/lib.c index 1b6238812..5e932a384 100644 --- a/src/viewer/lib.c +++ b/src/viewer/lib.c @@ -250,7 +250,7 @@ mcview_done (mcview_t * view) if (mc_global.mc_run_mode == MC_RUN_VIEWER && view->dir != NULL) { /* mcviewer is the owner of file list */ - clean_dir (view->dir); + dir_list_clean (view->dir); g_free (view->dir->list); g_free (view->dir_idx); g_free (view->dir);