2 * \brief Header: directory routines
10 #include "lib/global.h"
12 #include "lib/vfs/vfs.h"
14 /*** typedefs(not structures) and defined constants **********************************************/
16 #define DIR_LIST_MIN_SIZE 128
17 #define DIR_LIST_RESIZE_STEP 128
19 /*** enums ***************************************************************************************/
21 /*** structures declarations (and typedefs of structures)*****************************************/
24 * A structure to represent directory content
28 file_entry_t
*list
; /**< list of file_entry_t objects */
29 int size
; /**< number of allocated elements in list (capacity) */
30 int len
; /**< number of used elements in list */
34 * A structure to represent sort options for directory content
36 typedef struct dir_sort_options_struct
38 gboolean reverse
; /**< sort is reverse */
39 gboolean case_sensitive
; /**< sort is case sensitive */
40 gboolean exec_first
; /**< executables are at top of list */
43 /*** global variables defined in .c file *********************************************************/
45 /*** declarations of public functions ************************************************************/
47 gboolean
dir_list_grow (dir_list
* list
, int delta
);
48 gboolean
dir_list_append (dir_list
* list
, const char *fname
, const struct stat
*st
,
49 gboolean link_to_dir
, gboolean stale_link
);
51 void dir_list_load (dir_list
* list
, const vfs_path_t
* vpath
, GCompareFunc sort
,
52 const dir_sort_options_t
* sort_op
, const char *fltr
);
53 void dir_list_reload (dir_list
* list
, const vfs_path_t
* vpath
, GCompareFunc sort
,
54 const dir_sort_options_t
* sort_op
, const char *fltr
);
55 void dir_list_sort (dir_list
* list
, GCompareFunc sort
, const dir_sort_options_t
* sort_op
);
56 gboolean
dir_list_init (dir_list
* list
);
57 void dir_list_clean (dir_list
* list
);
58 gboolean
handle_path (const char *path
, struct stat
*buf1
, int *link_to_dir
, int *stale_link
);
60 /* Sorting functions */
61 int unsorted (file_entry_t
* a
, file_entry_t
* b
);
62 int sort_name (file_entry_t
* a
, file_entry_t
* b
);
63 int sort_vers (file_entry_t
* a
, file_entry_t
* b
);
64 int sort_ext (file_entry_t
* a
, file_entry_t
* b
);
65 int sort_time (file_entry_t
* a
, file_entry_t
* b
);
66 int sort_atime (file_entry_t
* a
, file_entry_t
* b
);
67 int sort_ctime (file_entry_t
* a
, file_entry_t
* b
);
68 int sort_size (file_entry_t
* a
, file_entry_t
* b
);
69 int sort_inode (file_entry_t
* a
, file_entry_t
* b
);
71 gboolean
if_link_is_exe (const vfs_path_t
* full_name
, const file_entry_t
* file
);
73 /*** inline functions ****************************************************************************/
75 static inline gboolean
76 link_isdir (const file_entry_t
* file
)
78 return (gboolean
) file
->f
.link_to_dir
;
81 #endif /* MC__DIR_H */