Moved charsets.[ch] from src to lib directory
[midnight-commander.git] / src / dir.h
blob394c849c17428d9b75510e67af19ac1ef9022a32
1 /** \file dir.h
2 * \brief Header: directory routines
3 */
5 #ifndef MC__DIR_H
6 #define MC__DIR_H
8 #include <sys/stat.h>
10 #include "lib/global.h"
12 /*** typedefs(not structures) and defined constants **********************************************/
14 #define MIN_FILES 128
15 #define RESIZE_STEPS 128
17 typedef int sortfn (const void *, const void *);
19 /*** enums ***************************************************************************************/
21 /*** structures declarations (and typedefs of structures)*****************************************/
23 /* keys are set only during sorting */
24 typedef struct
26 /* File attributes */
27 size_t fnamelen;
28 char *fname;
29 struct stat st;
30 /* key used for comparing names */
31 char *sort_key;
32 /* key used for comparing extensions */
33 char *second_sort_key;
35 /* Flags */
36 struct
38 unsigned int marked:1; /* File marked in pane window */
39 unsigned int link_to_dir:1; /* If this is a link, does it point to directory? */
40 unsigned int stale_link:1; /* If this is a symlink and points to Charon's land */
41 unsigned int dir_size_computed:1; /* Size of directory was computed with dirsizes_cmd */
42 } f;
43 } file_entry;
45 typedef struct
47 file_entry *list;
48 int size;
49 } dir_list;
51 /*** global variables defined in .c file *********************************************************/
53 /*** declarations of public functions ************************************************************/
55 int do_load_dir (const char *path, dir_list * list, sortfn * sort, int reverse,
56 int case_sensitive, int exec_ff, const char *fltr);
57 void do_sort (dir_list * list, sortfn * sort, int top, int reverse,
58 int case_sensitive, int exec_ff);
59 int do_reload_dir (const char *path, dir_list * list, sortfn * sort, int count,
60 int reverse, int case_sensitive, int exec_ff, const char *fltr);
61 void clean_dir (dir_list * list, int count);
62 gboolean set_zero_dir (dir_list * list);
63 int handle_path (dir_list * list, const char *path, struct stat *buf1,
64 int next_free, int *link_to_dir, int *stale_link);
66 /* Sorting functions */
67 int unsorted (file_entry * a, file_entry * b);
68 int sort_name (file_entry * a, file_entry * b);
69 int sort_vers (file_entry * a, file_entry * b);
70 int sort_ext (file_entry * a, file_entry * b);
71 int sort_time (file_entry * a, file_entry * b);
72 int sort_atime (file_entry * a, file_entry * b);
73 int sort_ctime (file_entry * a, file_entry * b);
74 int sort_size (file_entry * a, file_entry * b);
75 int sort_inode (file_entry * a, file_entry * b);
77 gboolean if_link_is_exe (const char *full_name, const file_entry * file);
79 /*** inline functions ****************************************************************************/
81 static inline gboolean
82 link_isdir (const file_entry *file)
84 return (gboolean) file->f.link_to_dir;
87 #endif /* MC__DIR_H */