r246: Added support for i18n. No translations yet, though!
[rox-filer/ma.git] / ROX-Filer / src / fscache.h
blob2345ad096e2d2f8309626e3d2ecb2ac299b6ff70
1 /*
2 * $Id$
4 * Thomas Leonard, <tal197@ecs.soton.ac.uk>
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>
16 #include <glib.h>
18 typedef struct _GFSCache GFSCache;
19 typedef struct _GFSCacheKey GFSCacheKey;
20 typedef struct _GFSCacheData GFSCacheData;
21 typedef gpointer (*GFSLoadFunc)(char *pathname, gpointer user_data);
22 typedef void (*GFSRefFunc)(gpointer object, gpointer user_data);
23 typedef int (*GFSGetRefFunc)(gpointer object, gpointer user_data);
24 typedef void (*GFSUpdateFunc)(gpointer object,
25 char *pathname,
26 gpointer user_data);
28 struct _GFSCache
31 GHashTable *inode_to_stats;
32 GFSLoadFunc load;
33 GFSRefFunc ref;
34 GFSRefFunc unref;
35 GFSGetRefFunc getref;
36 GFSUpdateFunc update;
37 gpointer user_data;
40 struct _GFSCacheKey
42 dev_t device;
43 ino_t inode;
46 struct _GFSCacheData
48 gpointer data; /* The object from the file */
49 time_t last_lookup;
51 /* Details of the file last time we checked it */
52 time_t m_time;
53 off_t length;
54 mode_t mode;
57 GFSCache *g_fscache_new(GFSLoadFunc load,
58 GFSRefFunc ref,
59 GFSRefFunc unref,
60 GFSGetRefFunc getref,
61 GFSUpdateFunc update,
62 gpointer user_data);
63 void g_fscache_destroy(GFSCache *cache);
64 gpointer g_fscache_lookup(GFSCache *cache, char *pathname);
65 void g_fscache_may_update(GFSCache *cache, char *pathname);
66 void g_fscache_update(GFSCache *cache, char *pathname);
67 void g_fscache_purge(GFSCache *cache, gint age);
69 void g_fscache_data_ref(GFSCache *cache, gpointer data);
70 void g_fscache_data_unref(GFSCache *cache, gpointer data);
72 #endif /* _FSCACHE_H */