root/src/filemanager/dir.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. link_isdir

   1 /** \file dir.h
   2  *  \brief Header: directory routines
   3  */
   4 
   5 #ifndef MC__DIR_H
   6 #define MC__DIR_H
   7 
   8 #include <sys/stat.h>
   9 
  10 #include "lib/global.h"
  11 #include "lib/search.h"
  12 #include "lib/util.h"
  13 #include "lib/vfs/vfs.h"
  14 
  15 /*** typedefs(not structures) and defined constants **********************************************/
  16 
  17 #define DIR_LIST_MIN_SIZE 128
  18 #define DIR_LIST_RESIZE_STEP 128
  19 
  20 typedef enum
  21 {
  22     DIR_OPEN = 0,
  23     DIR_READ,
  24     DIR_CLOSE
  25 } dir_list_cb_state_t;
  26 
  27 /* selection flags */
  28 typedef enum
  29 {
  30     SELECT_FILES_ONLY = 1 << 0,
  31     SELECT_MATCH_CASE = 1 << 1,
  32     SELECT_SHELL_PATTERNS = 1 << 2
  33 } select_flags_t;
  34 
  35 #define FILE_FILTER_DEFAULT_FLAGS (SELECT_FILES_ONLY | SELECT_MATCH_CASE | SELECT_SHELL_PATTERNS)
  36 
  37 /* dir_list callback */
  38 typedef void (*dir_list_cb_fn) (dir_list_cb_state_t state, void *data);
  39 
  40 /*** enums ***************************************************************************************/
  41 
  42 /*** structures declarations (and typedefs of structures)*****************************************/
  43 
  44 /**
  45  * A structure to represent directory content
  46  */
  47 typedef struct
  48 {
  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 */
  53 } dir_list;
  54 
  55 /**
  56  * A structure to represent sort options for directory content
  57  */
  58 typedef struct dir_sort_options_struct
  59 {
  60     gboolean reverse;           /**< sort is reverse */
  61     gboolean case_sensitive;    /**< sort is case sensitive */
  62     gboolean exec_first;        /**< executables are at top of list */
  63 } dir_sort_options_t;
  64 
  65 /* filter  */
  66 typedef struct
  67 {
  68     char *value;
  69     mc_search_t *handler;
  70     select_flags_t flags;
  71 } file_filter_t;
  72 
  73 /*** global variables defined in .c file *********************************************************/
  74 
  75 /*** declarations of public functions ************************************************************/
  76 
  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);
  80 
  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);
  91 
  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);
 102 
 103 gboolean if_link_is_exe (const vfs_path_t * full_name, const file_entry_t * file);
 104 
 105 void file_filter_clear (file_filter_t * filter);
 106 
 107 /*** inline functions ****************************************************************************/
 108 
 109 static inline gboolean
 110 link_isdir (const file_entry_t * file)
     /* [previous][next][first][last][top][bottom][index][help]  */
 111 {
 112     return (gboolean) file->f.link_to_dir;
 113 }
 114 
 115 #endif /* MC__DIR_H */

/* [previous][next][first][last][top][bottom][index][help]  */