15typedef struct gp_dir_entry {
18 unsigned int name_len;
24typedef struct gp_dir_cache {
26 struct gp_balloc_pool *allocator;
30 struct gp_dir_entry **entries;
40gp_dir_cache *gp_dir_cache_new(
const char *path);
47void gp_dir_cache_destroy(gp_dir_cache *self);
60gp_dir_entry *gp_dir_cache_add_entry(gp_dir_cache *self,
size_t size,
61 const char *name, mode_t mode, time_t mtime);
71int gp_dir_cache_rem_entry_by_name(gp_dir_cache *self,
const char *name);
80gp_dir_entry *gp_dir_cache_entry_lookup(gp_dir_cache *self,
const char *name);
87int gp_dir_cache_entry_name_contains(gp_dir_cache *self,
const char *needle);
96void gp_dir_cache_free_entries(gp_dir_cache *self);
98enum gp_dir_cache_sort_type {
99 GP_DIR_SORT_ASC = 0x00,
100 GP_DIR_SORT_DESC = 0x04,
101 GP_DIR_SORT_BY_NAME = 0x00,
102 GP_DIR_SORT_BY_SIZE = 0x01,
103 GP_DIR_SORT_BY_MTIME = 0x02,
106void gp_dir_cache_sort(gp_dir_cache *self,
int sort_type);
108static inline gp_dir_entry *gp_dir_cache_get(gp_dir_cache *self,
111 if (self->used <= pos)
114 return self->entries[pos];
124static inline void gp_dir_cache_set_filter(gp_dir_cache *self,
unsigned int pos,
127 if (self->entries[pos]->filtered == !!filter)
130 self->entries[pos]->filtered = !!filter;
131 self->filtered += filter ? 1 : -1;
139static inline size_t gp_dir_cache_entries(gp_dir_cache *self)
149static inline size_t gp_dir_cache_entries_filter(gp_dir_cache *self)
151 return self->used - self->filtered;
161gp_dir_entry *gp_dir_cache_get_filtered(gp_dir_cache *self,
unsigned int pos);
172int gp_dir_cache_notify(gp_dir_cache *self);
180gp_fd *gp_dir_cache_notify_fd(gp_dir_cache *self);
189int gp_dir_cache_mkdir(gp_dir_cache *self,
const char *dirname);
198unsigned int gp_dir_cache_pos_by_name_filtered(gp_dir_cache *self,
const char *name);
202enum gp_dir_cache_type {
203 GP_DIR_CACHE_NONE = 0,
204 GP_DIR_CACHE_FILE = 1,
205 GP_DIR_CACHE_DIR = 2,
214enum gp_dir_cache_type gp_dir_cache_lookup(gp_dir_cache *self,
const char *name);
An epoll file descriptor.