ce7afc0e55156428a1420d803af4f479753404e2
[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         long checksum;
44         guchar md5sum[16];
45         ImageSimilarityData *sim;
46
47         gint dimensions;
48         gint have_checksum;
49         gint have_md5sum;
50         gint similarity;
51 };
52
53 gint cache_time_valid(const gchar *cache, const gchar *path);
54
55
56 CacheData *cache_sim_data_new(void);
57 void cache_sim_data_free(CacheData *cd);
58
59 gint cache_sim_data_save(CacheData *cd);
60 CacheData *cache_sim_data_load(const gchar *path);
61
62 void cache_sim_data_set_dimensions(CacheData *cd, gint w, gint h);
63 void cache_sim_data_set_checksum(CacheData *cd, long checksum);
64 void cache_sim_data_set_md5sum(CacheData *cd, guchar digest[16]);
65 void cache_sim_data_set_similarity(CacheData *cd, ImageSimilarityData *sd);
66 gint cache_sim_data_filled(ImageSimilarityData *sd);
67
68
69 gint cache_ensure_dir_exists(gchar *path, mode_t mode);
70 gchar *cache_get_location(CacheType type, const gchar *source, gint include_name, mode_t *mode);
71 gchar *cache_find_location(CacheType type, const gchar *source);
72
73
74 #endif
75
76