2 * \brief Header: directory routines
10 #include "lib/global.h"
11 #include "lib/search.h"
12 #include "lib/file-entry.h"
13 #include "lib/vfs/vfs.h"
15 /*** typedefs(not structures) and defined constants **********************************************/
17 #define DIR_LIST_MIN_SIZE 128
18 #define DIR_LIST_RESIZE_STEP 128
25 } dir_list_cb_state_t
;
30 SELECT_FILES_ONLY
= 1 << 0,
31 SELECT_MATCH_CASE
= 1 << 1,
32 SELECT_SHELL_PATTERNS
= 1 << 2
35 #define FILE_FILTER_DEFAULT_FLAGS (SELECT_FILES_ONLY | SELECT_MATCH_CASE | SELECT_SHELL_PATTERNS)
37 /* dir_list callback */
38 typedef void (*dir_list_cb_fn
) (dir_list_cb_state_t state
, void *data
);
40 /*** enums ***************************************************************************************/
42 /*** structures declarations (and typedefs of structures)*****************************************/
45 * A structure to represent directory content
49 file_entry_t
*list
; /**< list of file_entry_t objects */
50 int size
; /**< number of allocated elements in list (capacity) */
51 int len
; /**< number of used elements in list */
52 dir_list_cb_fn callback
; /**< callback to visualize of directory read */
56 * A structure to represent sort options for directory content
58 typedef struct dir_sort_options_struct
60 gboolean reverse
; /**< sort is reverse */
61 gboolean case_sensitive
; /**< sort is case sensitive */
62 gboolean exec_first
; /**< executables are at top of list */
73 /*** global variables defined in .c file *********************************************************/
75 /*** declarations of public functions ************************************************************/
77 gboolean
dir_list_grow (dir_list
* list
, int delta
);
78 gboolean
dir_list_append (dir_list
* list
, const char *fname
, const struct stat
*st
,
79 gboolean link_to_dir
, gboolean stale_link
);
81 gboolean
dir_list_load (dir_list
* list
, const vfs_path_t
* vpath
, GCompareFunc sort
,
82 const dir_sort_options_t
* sort_op
, const file_filter_t
* filter
);
83 gboolean
dir_list_reload (dir_list
* list
, const vfs_path_t
* vpath
, GCompareFunc sort
,
84 const dir_sort_options_t
* sort_op
, const file_filter_t
* filter
);
85 void dir_list_sort (dir_list
* list
, GCompareFunc sort
, const dir_sort_options_t
* sort_op
);
86 gboolean
dir_list_init (dir_list
* list
);
87 void dir_list_clean (dir_list
* list
);
88 void dir_list_free_list (dir_list
* list
);
89 gboolean
handle_path (const char *path
, struct stat
*buf1
, gboolean
* link_to_dir
,
90 gboolean
* stale_link
);
92 /* Sorting functions */
93 int unsorted (file_entry_t
* a
, file_entry_t
* b
);
94 int sort_name (file_entry_t
* a
, file_entry_t
* b
);
95 int sort_vers (file_entry_t
* a
, file_entry_t
* b
);
96 int sort_ext (file_entry_t
* a
, file_entry_t
* b
);
97 int sort_time (file_entry_t
* a
, file_entry_t
* b
);
98 int sort_atime (file_entry_t
* a
, file_entry_t
* b
);
99 int sort_ctime (file_entry_t
* a
, file_entry_t
* b
);
100 int sort_size (file_entry_t
* a
, file_entry_t
* b
);
101 int sort_inode (file_entry_t
* a
, file_entry_t
* b
);
103 gboolean
if_link_is_exe (const vfs_path_t
* full_name
, const file_entry_t
* file
);
105 void file_filter_clear (file_filter_t
* filter
);
107 /*** inline functions ****************************************************************************/
109 static inline gboolean
110 link_isdir (const file_entry_t
*file
)
112 return (file
->f
.link_to_dir
!= 0);
115 #endif /* MC__DIR_H */