mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-22 03:02:06 +03:00
Add dir_list callback to visualize of directory reading.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
8c5737f558
commit
284c3de727
@ -72,7 +72,7 @@ static gboolean case_sensitive = OS_SORT_CASE_SENSITIVE_DEFAULT;
|
||||
/* Are the exec_bit files top in list */
|
||||
static gboolean exec_first = TRUE;
|
||||
|
||||
static dir_list dir_copy = { NULL, 0, 0 };
|
||||
static dir_list dir_copy = { NULL, 0, 0, NULL };
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -638,6 +638,8 @@ dir_list_load (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
|
||||
if (dir_get_dotdot_stat (vpath, &st))
|
||||
fentry->st = st;
|
||||
|
||||
if (list->callback != NULL)
|
||||
list->callback (DIR_OPEN, (void *) vpath);
|
||||
dirp = mc_opendir (vpath);
|
||||
if (dirp == NULL)
|
||||
return FALSE;
|
||||
@ -653,6 +655,9 @@ dir_list_load (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
|
||||
{
|
||||
gboolean link_to_dir, stale_link;
|
||||
|
||||
if (list->callback != NULL)
|
||||
list->callback (DIR_READ, dp);
|
||||
|
||||
if (!handle_dirent (dp, fltr, &st, &link_to_dir, &stale_link))
|
||||
continue;
|
||||
|
||||
@ -669,6 +674,8 @@ dir_list_load (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
|
||||
dir_list_sort (list, sort, sort_op);
|
||||
|
||||
ret:
|
||||
if (list->callback != NULL)
|
||||
list->callback (DIR_CLOSE, NULL);
|
||||
mc_closedir (dirp);
|
||||
tree_store_end_check ();
|
||||
rotate_dash (FALSE);
|
||||
@ -703,6 +710,8 @@ dir_list_reload (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
|
||||
GHashTable *marked_files;
|
||||
const char *tmp_path;
|
||||
|
||||
if (list->callback != NULL)
|
||||
list->callback (DIR_OPEN, (void *) vpath);
|
||||
dirp = mc_opendir (vpath);
|
||||
if (dirp == NULL)
|
||||
{
|
||||
@ -771,11 +780,16 @@ dir_list_reload (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
|
||||
file_entry_t *fentry;
|
||||
gboolean link_to_dir, stale_link;
|
||||
|
||||
if (list->callback != NULL)
|
||||
list->callback (DIR_READ, dp);
|
||||
|
||||
if (!handle_dirent (dp, fltr, &st, &link_to_dir, &stale_link))
|
||||
continue;
|
||||
|
||||
if (!dir_list_append (list, dp->d_name, &st, link_to_dir, stale_link))
|
||||
{
|
||||
if (list->callback != NULL)
|
||||
list->callback (DIR_CLOSE, NULL);
|
||||
mc_closedir (dirp);
|
||||
/* Norbert (Feb 12, 1997):
|
||||
Just in case someone finds this memory leak:
|
||||
@ -809,7 +823,11 @@ dir_list_reload (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
|
||||
if ((list->len & 15) == 0)
|
||||
rotate_dash (TRUE);
|
||||
}
|
||||
|
||||
if (list->callback != NULL)
|
||||
list->callback (DIR_CLOSE, NULL);
|
||||
mc_closedir (dirp);
|
||||
|
||||
tree_store_end_check ();
|
||||
g_hash_table_destroy (marked_files);
|
||||
|
||||
|
@ -16,6 +16,16 @@
|
||||
#define DIR_LIST_MIN_SIZE 128
|
||||
#define DIR_LIST_RESIZE_STEP 128
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DIR_OPEN = 0,
|
||||
DIR_READ,
|
||||
DIR_CLOSE
|
||||
} dir_list_cb_state_t;
|
||||
|
||||
/* dir_list callback */
|
||||
typedef void (*dir_list_cb_fn) (dir_list_cb_state_t state, void *data);
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
@ -28,6 +38,7 @@ typedef struct
|
||||
file_entry_t *list; /**< list of file_entry_t objects */
|
||||
int size; /**< number of allocated elements in list (capacity) */
|
||||
int len; /**< number of used elements in list */
|
||||
dir_list_cb_fn callback; /**< callback to visualize of directory read */
|
||||
} dir_list;
|
||||
|
||||
/**
|
||||
|
@ -85,7 +85,7 @@
|
||||
hook_t *select_file_hook = NULL;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
panelized_panel_t panelized_panel = { {NULL, 0, -1}, NULL };
|
||||
panelized_panel_t panelized_panel = { {NULL, 0, -1, NULL}, NULL };
|
||||
/* *INDENT-ON* */
|
||||
|
||||
static const char *string_file_name (file_entry_t *, int);
|
||||
|
Loading…
Reference in New Issue
Block a user