Wed Apr 13 18:16:14 2005 John Ellis <johne@verizon.net>
[geeqie.git] / src / cache.h
1 /*
2  * GQview
3  * (C) 2004 John Ellis
4  *
5  * Author: John Ellis
6  *
7  * This software is released under the GNU General Public License (GNU GPL).
8  * Please read the included file COPYING for more information.
9  * This software comes with no warranty of any kind, use at your own risk!
10  */
11
12
13 #ifndef CACHE_H
14 #define CACHE_H
15
16
17 #include "similar.h"
18
19
20 #define GQVIEW_CACHE_RC_THUMB       GQVIEW_RC_DIR"/thumbnails"
21 #define GQVIEW_CACHE_RC_METADATA    GQVIEW_RC_DIR"/metadata"
22
23 #define GQVIEW_CACHE_LOCAL_THUMB    ".thumbnails"
24 #define GQVIEW_CACHE_LOCAL_METADATA ".metadata"
25
26 #define GQVIEW_CACHE_EXT_THUMB      ".png"
27 #define GQVIEW_CACHE_EXT_SIM        ".sim"
28 #define GQVIEW_CACHE_EXT_METADATA   ".meta"
29
30
31 typedef enum {
32         CACHE_TYPE_THUMB,
33         CACHE_TYPE_SIM,
34         CACHE_TYPE_METADATA
35 } CacheType;
36
37 typedef struct _CacheData CacheData;
38 struct _CacheData
39 {
40         gchar *path;
41         gint width;
42         gint height;
43         time_t date;
44         long checksum;
45         guchar md5sum[16];
46         ImageSimilarityData *sim;
47
48         gint dimensions;
49         gint have_date;
50         gint have_checksum;
51         gint have_md5sum;
52         gint similarity;
53 };
54
55 gint cache_time_valid(const gchar *cache, const gchar *path);
56
57
58 CacheData *cache_sim_data_new(void);
59 void cache_sim_data_free(CacheData *cd);
60
61 gint cache_sim_data_save(CacheData *cd);
62 CacheData *cache_sim_data_load(const gchar *path);
63
64 void cache_sim_data_set_dimensions(CacheData *cd, gint w, gint h);
65 void cache_sim_data_set_date(CacheData *cd, time_t date);
66 void cache_sim_data_set_checksum(CacheData *cd, long checksum);
67 void cache_sim_data_set_md5sum(CacheData *cd, guchar digest[16]);
68 void cache_sim_data_set_similarity(CacheData *cd, ImageSimilarityData *sd);
69 gint cache_sim_data_filled(ImageSimilarityData *sd);
70
71
72 gint cache_ensure_dir_exists(gchar *path, mode_t mode);
73 gchar *cache_get_location(CacheType type, const gchar *source, gint include_name, mode_t *mode);
74 gchar *cache_find_location(CacheType type, const gchar *source);
75
76
77 #endif
78
79