-
Notifications
You must be signed in to change notification settings - Fork 1
/
filelist_cache.h
36 lines (29 loc) · 867 Bytes
/
filelist_cache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include "htable.h"
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#define PATH_SIZE 256
typedef struct {
char basedir[PATH_SIZE];
HTable *files;
pthread_mutex_t *lock;
} filelist_cache_t;
enum file_kind_t {
FK_FILE,
FK_FOLDER
};
typedef struct {
HTableNode node;
char filename[PATH_SIZE];
size_t filesize;
enum file_kind_t kind;
unsigned long mtime;
} filelist_cache_data_t;
filelist_cache_t *filelist_cache_create(void);
void filelist_cache_insert(filelist_cache_t *cache, filelist_cache_data_t *data);
filelist_cache_data_t *filelist_cache_find(filelist_cache_t *cache, const char *path);
void filelist_cache_clean(filelist_cache_t *cache);
void filelist_cache_free(filelist_cache_t *cache);
void filelist_cache_lock(filelist_cache_t *cache);
void filelist_cache_unlock(filelist_cache_t *cache);