107 const char *name, mode_t mode, time_t mtime);
169 if (self->
used <= pos)
int gp_dir_cache_entry_name_contains(gp_dir_cache *self, const char *needle)
Returns true if there is at least one entry with needle in the name.
gp_dir_cache_type
A cache entry lookup type.
@ GP_DIR_CACHE_DIR
A directory type element found.
@ GP_DIR_CACHE_NONE
No element found.
@ GP_DIR_CACHE_FILE
File type element found.
static size_t gp_dir_cache_entries(gp_dir_cache *self)
Returns number of entries.
static void gp_dir_cache_set_filter(gp_dir_cache *self, unsigned int pos, int filter)
Sets dir cache entry filter flag.
int gp_dir_cache_notify(gp_dir_cache *self)
A change notify handler.
gp_dir_entry * gp_dir_cache_entry_lookup(gp_dir_cache *self, const char *name)
Looks up an entry based on a file name.
void gp_dir_cache_sort(gp_dir_cache *self, gp_dir_cache_sort_type sort_type)
Sorts the directory cache entries.
gp_dir_entry * gp_dir_cache_add_entry(gp_dir_cache *self, size_t size, const char *name, mode_t mode, time_t mtime)
Adds an entry to the directory cache.
gp_dir_cache * gp_dir_cache_new(const char *path)
Creates and populates a new directory cache.
int gp_dir_cache_rem_entry_by_name(gp_dir_cache *self, const char *name)
Removes an entry from directory cache.
int gp_dir_cache_mkdir(gp_dir_cache *self, const char *dirname)
Creates a directory and updates the cache.
void gp_dir_cache_destroy(gp_dir_cache *self)
Destroys a directory cache.
static size_t gp_dir_cache_entries_filter(gp_dir_cache *self)
Returns number of not-filtered entries.
gp_fd * gp_dir_cache_notify_fd(gp_dir_cache *self)
Returns inotify fd if available.
void gp_dir_cache_free_entries(gp_dir_cache *self)
Frees all entries from directory cache.
gp_dir_entry * gp_dir_cache_get_filtered(gp_dir_cache *self, unsigned int pos)
Returns entry on position pos ignoring filtered out elements.
enum gp_dir_cache_type gp_dir_cache_lookup(gp_dir_cache *self, const char *name)
Looks for a file in the directory the cache operates in.
unsigned int gp_dir_cache_pos_by_name_filtered(gp_dir_cache *self, const char *name)
Looks up a entry position by name.
static gp_dir_entry * gp_dir_cache_get(gp_dir_cache *self, unsigned int pos)
Returns an entry given a position.
gp_dir_cache_sort_type
How should be the listing sorted.
@ GP_DIR_SORT_BY_MTIME
Sort by modification time.
@ GP_DIR_SORT_BY_SIZE
Sort by size.
@ GP_DIR_SORT_DESC
Sort in a descending order.
@ GP_DIR_SORT_BY_NAME
Sort by name.
@ GP_DIR_SORT_ASC
Sort in an ascending order.
A block allocator block header.
size_t used
Number of used entries.
gp_dir_entry ** entries
An array of dir cache entres sorted accordingly to sort_type.
enum gp_dir_cache_sort_type sort_type
An order the listing is sorted in.
struct gp_balloc_pool * allocator
A block allocator for the cache entries.
size_t size
The size of the cache.
size_t filtered
Number of filtered items.
A dir cache entry, represents a file or a directory.
int filtered
If set the entry is hidden from listing.
size_t size
Entry size in bytes.
unsigned int name_len
Length of the entry name.
time_t mtime
Entry modification time.
int is_dir
Set if entry is a directory.
An epoll file descriptor.