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