Merge branch '44_more_functionally_u7z'
[pantumic.git] / src / dir.h
blob9ee0096428a91d04a249ec310e1aee73ffb5d25f
2 /** \file dir.h
3 * \brief Header: directory routines
4 */
6 #ifndef MC_DIR_H
7 #define MC_DIR_H
9 #define MIN_FILES 128
10 #define RESIZE_STEPS 128
12 #include <sys/stat.h>
14 /* keys are set only during sorting */
15 typedef struct {
17 /* File attributes */
19 int fnamelen;
20 char *fname;
21 struct stat st;
22 /* key used for comparing names */
23 char *sort_key;
24 /* key used for comparing extensions */
25 char *second_sort_key;
27 /* Flags */
28 struct {
29 unsigned int marked:1; /* File marked in pane window */
30 unsigned int link_to_dir:1; /* If this is a link, does it point to directory? */
31 unsigned int stale_link:1; /* If this is a symlink and points to Charon's land */
32 unsigned int dir_size_computed:1; /* Size of directory was computed with dirsizes_cmd */
33 } f;
34 } file_entry;
36 typedef struct {
37 file_entry *list;
38 int size;
39 } dir_list;
41 typedef int sortfn (const void *, const void *);
43 int do_load_dir (const char *path, dir_list * list, sortfn * sort, int reverse,
44 int case_sensitive, int exec_ff, const char *filter);
45 void do_sort (dir_list * list, sortfn * sort, int top, int reverse,
46 int case_sensitive, int exec_ff);
47 int do_reload_dir (const char *path, dir_list * list, sortfn * sort, int count,
48 int reverse, int case_sensitive, int exec_ff, const char *filter);
49 void clean_dir (dir_list * list, int count);
50 int set_zero_dir (dir_list * list);
51 int handle_path (dir_list *list, const char *path, struct stat *buf1,
52 int next_free, int *link_to_dir, int *stale_link);
54 /* Sorting functions */
55 int unsorted (file_entry *a, file_entry *b);
56 int sort_name (file_entry *a, file_entry *b);
57 int sort_ext (file_entry *a, file_entry *b);
58 int sort_time (file_entry *a, file_entry *b);
59 int sort_atime (file_entry *a, file_entry *b);
60 int sort_ctime (file_entry *a, file_entry *b);
61 int sort_size (file_entry *a, file_entry *b);
62 int sort_inode (file_entry *a, file_entry *b);
64 /* SORT_TYPES is used to build the nice dialog box entries */
65 #define SORT_TYPES 8
67 /* This is the number of sort types not available in that dialog box */
68 #define SORT_TYPES_EXTRA 0
70 /* The total nnumber of sort types */
71 #define SORT_TYPES_TOTAL (SORT_TYPES + SORT_TYPES_EXTRA)
73 typedef struct {
74 const char *sort_name;
75 int (*sort_fn)(file_entry *, file_entry *);
76 } sort_orders_t;
78 extern sort_orders_t sort_orders [SORT_TYPES_TOTAL];
80 int link_isdir (const file_entry *);
81 int if_link_is_exe (const char *full_name, const file_entry *file);
83 extern int show_backups;
84 extern int show_dot_files;
85 extern int mix_all_files;
86 extern int kilobyte_si;
88 #endif