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/util.h"
  12 #include "lib/vfs/vfs.h"
  13 
  14 /*** typedefs(not structures) and defined constants **********************************************/
  15 
  16 #define DIR_LIST_MIN_SIZE 128
  17 #define DIR_LIST_RESIZE_STEP 128
  18 
  19 typedef enum
  20 {
  21     DIR_OPEN = 0,
  22     DIR_READ,
  23     DIR_CLOSE
  24 } dir_list_cb_state_t;
  25 
  26 /* dir_list callback */
  27 typedef void (*dir_list_cb_fn) (dir_list_cb_state_t state, void *data);
  28 
  29 /*** enums ***************************************************************************************/
  30 
  31 /*** structures declarations (and typedefs of structures)*****************************************/
  32 
  33 /**
  34  * A structure to represent directory content
  35  */
  36 typedef struct
  37 {
  38     file_entry_t *list; /**< list of file_entry_t objects */
  39     int size;           /**< number of allocated elements in list (capacity) */
  40     int len;            /**< number of used elements in list */
  41     dir_list_cb_fn callback;    /**< callback to visualize of directory read */
  42 } dir_list;
  43 
  44 /**
  45  * A structure to represent sort options for directory content
  46  */
  47 typedef struct dir_sort_options_struct
  48 {
  49     gboolean reverse;           /**< sort is reverse */
  50     gboolean case_sensitive;    /**< sort is case sensitive */
  51     gboolean exec_first;        /**< executables are at top of list */
  52 } dir_sort_options_t;
  53 
  54 /*** global variables defined in .c file *********************************************************/
  55 
  56 /*** declarations of public functions ************************************************************/
  57 
  58 gboolean dir_list_grow (dir_list * list, int delta);
  59 gboolean dir_list_append (dir_list * list, const char *fname, const struct stat *st,
  60                           gboolean link_to_dir, gboolean stale_link);
  61 
  62 gboolean dir_list_load (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
  63                         const dir_sort_options_t * sort_op, const char *fltr);
  64 gboolean dir_list_reload (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
  65                           const dir_sort_options_t * sort_op, const char *fltr);
  66 void dir_list_sort (dir_list * list, GCompareFunc sort, const dir_sort_options_t * sort_op);
  67 gboolean dir_list_init (dir_list * list);
  68 void dir_list_clean (dir_list * list);
  69 void dir_list_free_list (dir_list * list);
  70 gboolean handle_path (const char *path, struct stat *buf1, gboolean * link_to_dir,
  71                       gboolean * stale_link);
  72 
  73 /* Sorting functions */
  74 int unsorted (file_entry_t * a, file_entry_t * b);
  75 int sort_name (file_entry_t * a, file_entry_t * b);
  76 int sort_vers (file_entry_t * a, file_entry_t * b);
  77 int sort_ext (file_entry_t * a, file_entry_t * b);
  78 int sort_time (file_entry_t * a, file_entry_t * b);
  79 int sort_atime (file_entry_t * a, file_entry_t * b);
  80 int sort_ctime (file_entry_t * a, file_entry_t * b);
  81 int sort_size (file_entry_t * a, file_entry_t * b);
  82 int sort_inode (file_entry_t * a, file_entry_t * b);
  83 
  84 gboolean if_link_is_exe (const vfs_path_t * full_name, const file_entry_t * file);
  85 
  86 /*** inline functions ****************************************************************************/
  87 
  88 static inline gboolean
  89 link_isdir (const file_entry_t * file)
     /* [previous][next][first][last][top][bottom][index][help]  */
  90 {
  91     return (gboolean) file->f.link_to_dir;
  92 }
  93 
  94 #endif /* MC__DIR_H */

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