r1107: Added a configure check for iconv.h.
[rox-filer.git] / ROX-Filer / src / fscache.h
blob4f75e226a1323b4aa9bbe7673a060ea7b27593b9
1 /*
2 * $Id$
4 * Thomas Leonard, <tal197@users.sourceforge.net>
5 */
8 #ifndef _FSCACHE_H
9 #define _FSCACHE_H
11 #include <sys/stat.h>
12 #include <unistd.h>
13 #include <stdlib.h>
14 #include <time.h>
15 #include <glib.h>
17 typedef struct _GFSCacheKey GFSCacheKey;
18 typedef struct _GFSCacheData GFSCacheData;
19 typedef gpointer (*GFSLoadFunc)(char *pathname, gpointer user_data);
20 typedef void (*GFSRefFunc)(gpointer object, gpointer user_data);
21 typedef int (*GFSGetRefFunc)(gpointer object, gpointer user_data);
22 typedef void (*GFSUpdateFunc)(gpointer object,
23 char *pathname,
24 gpointer user_data);
26 struct _GFSCache
29 GHashTable *inode_to_stats;
30 GFSLoadFunc load;
31 GFSRefFunc ref;
32 GFSRefFunc unref;
33 GFSGetRefFunc getref;
34 GFSUpdateFunc update;
35 gpointer user_data;
38 struct _GFSCacheKey
40 dev_t device;
41 ino_t inode;
44 struct _GFSCacheData
46 gpointer data; /* The object from the file */
47 time_t last_lookup;
49 /* Details of the file last time we checked it */
50 time_t m_time;
51 off_t length;
52 mode_t mode;
55 typedef enum {
56 FSCACHE_LOOKUP_CREATE, /* Load if missing. Update as needed. */
57 FSCACHE_LOOKUP_ONLY_NEW,/* Return NULL if not present AND uptodate */
58 FSCACHE_LOOKUP_PEEK, /* Lookup; don't load or update */
59 FSCACHE_LOOKUP_INIT, /* Internal use */
60 } FSCacheLookup;
62 GFSCache *g_fscache_new(GFSLoadFunc load,
63 GFSRefFunc ref,
64 GFSRefFunc unref,
65 GFSGetRefFunc getref,
66 GFSUpdateFunc update,
67 gpointer user_data);
68 void g_fscache_destroy(GFSCache *cache);
69 gpointer g_fscache_lookup(GFSCache *cache, char *pathname);
70 gpointer g_fscache_lookup_full(GFSCache *cache, char *pathname,
71 FSCacheLookup lookup_type,
72 gboolean *found);
73 void g_fscache_may_update(GFSCache *cache, char *pathname);
74 void g_fscache_update(GFSCache *cache, char *pathname);
75 void g_fscache_purge(GFSCache *cache, gint age);
77 void g_fscache_data_ref(GFSCache *cache, gpointer data);
78 void g_fscache_data_unref(GFSCache *cache, gpointer data);
80 void g_fscache_insert(GFSCache *cache, char *pathname, gpointer obj);
82 #endif /* _FSCACHE_H */