Trim trailing white spaces on empty lines.
[geeqie.git] / src / cache.c
index 13e3d06..a3320b0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Geeqie
  * (C) 2004 John Ellis
- * Copyright (C) 2008 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Author: John Ellis
  *
@@ -74,7 +74,7 @@ void cache_sim_data_free(CacheData *cd)
  *-------------------------------------------------------------------
  */
 
-static gint cache_sim_write_dimensions(SecureSaveInfo *ssi, CacheData *cd)
+static gboolean cache_sim_write_dimensions(SecureSaveInfo *ssi, CacheData *cd)
 {
        if (!cd || !cd->dimensions) return FALSE;
 
@@ -83,7 +83,7 @@ static gint cache_sim_write_dimensions(SecureSaveInfo *ssi, CacheData *cd)
        return TRUE;
 }
 
-static gint cache_sim_write_date(SecureSaveInfo *ssi, CacheData *cd)
+static gboolean cache_sim_write_date(SecureSaveInfo *ssi, CacheData *cd)
 {
        if (!cd || !cd->have_date) return FALSE;
 
@@ -92,7 +92,7 @@ static gint cache_sim_write_date(SecureSaveInfo *ssi, CacheData *cd)
        return TRUE;
 }
 
-static gint cache_sim_write_checksum(SecureSaveInfo *ssi, CacheData *cd)
+static gboolean cache_sim_write_checksum(SecureSaveInfo *ssi, CacheData *cd)
 {
        if (!cd || !cd->have_checksum) return FALSE;
 
@@ -101,7 +101,7 @@ static gint cache_sim_write_checksum(SecureSaveInfo *ssi, CacheData *cd)
        return TRUE;
 }
 
-static gint cache_sim_write_md5sum(SecureSaveInfo *ssi, CacheData *cd)
+static gboolean cache_sim_write_md5sum(SecureSaveInfo *ssi, CacheData *cd)
 {
        gchar *text;
 
@@ -114,7 +114,7 @@ static gint cache_sim_write_md5sum(SecureSaveInfo *ssi, CacheData *cd)
        return TRUE;
 }
 
-static gint cache_sim_write_similarity(SecureSaveInfo *ssi, CacheData *cd)
+static gboolean cache_sim_write_similarity(SecureSaveInfo *ssi, CacheData *cd)
 {
        guint x, y;
        guint8 buf[3 * 32];
@@ -129,7 +129,7 @@ static gint cache_sim_write_similarity(SecureSaveInfo *ssi, CacheData *cd)
                guint8 *avg_g = &cd->sim->avg_g[s];
                guint8 *avg_b = &cd->sim->avg_b[s];
                guint n = 0;
-                       
+
                for (x = 0; x < 32; x++)
                        {
                        buf[n++] = avg_r[x];
@@ -145,7 +145,7 @@ static gint cache_sim_write_similarity(SecureSaveInfo *ssi, CacheData *cd)
        return TRUE;
 }
 
-gint cache_sim_data_save(CacheData *cd)
+gboolean cache_sim_data_save(CacheData *cd)
 {
        SecureSaveInfo *ssi;
        gchar *pathl;
@@ -185,7 +185,7 @@ gint cache_sim_data_save(CacheData *cd)
  *-------------------------------------------------------------------
  */
 
-static gint cache_sim_read_skipline(FILE *f, gint s)
+static gboolean cache_sim_read_skipline(FILE *f, gint s)
 {
        if (!f) return FALSE;
 
@@ -202,7 +202,7 @@ static gint cache_sim_read_skipline(FILE *f, gint s)
        return FALSE;
 }
 
-static gint cache_sim_read_comment(FILE *f, gchar *buf, gint s, CacheData *cd)
+static gboolean cache_sim_read_comment(FILE *f, gchar *buf, gint s, CacheData *cd)
 {
        if (!f || !buf || !cd) return FALSE;
 
@@ -211,7 +211,7 @@ static gint cache_sim_read_comment(FILE *f, gchar *buf, gint s, CacheData *cd)
        return cache_sim_read_skipline(f, s - 1);
 }
 
-static gint cache_sim_read_dimensions(FILE *f, gchar *buf, gint s, CacheData *cd)
+static gboolean cache_sim_read_dimensions(FILE *f, gchar *buf, gint s, CacheData *cd)
 {
        if (!f || !buf || !cd) return FALSE;
 
@@ -254,7 +254,7 @@ static gint cache_sim_read_dimensions(FILE *f, gchar *buf, gint s, CacheData *cd
        return FALSE;
 }
 
-static gint cache_sim_read_date(FILE *f, gchar *buf, gint s, CacheData *cd)
+static gboolean cache_sim_read_date(FILE *f, gchar *buf, gint s, CacheData *cd)
 {
        if (!f || !buf || !cd) return FALSE;
 
@@ -294,7 +294,7 @@ static gint cache_sim_read_date(FILE *f, gchar *buf, gint s, CacheData *cd)
        return FALSE;
 }
 
-static gint cache_sim_read_checksum(FILE *f, gchar *buf, gint s, CacheData *cd)
+static gboolean cache_sim_read_checksum(FILE *f, gchar *buf, gint s, CacheData *cd)
 {
        if (!f || !buf || !cd) return FALSE;
 
@@ -334,7 +334,7 @@ static gint cache_sim_read_checksum(FILE *f, gchar *buf, gint s, CacheData *cd)
        return FALSE;
 }
 
-static gint cache_sim_read_md5sum(FILE *f, gchar *buf, gint s, CacheData *cd)
+static gboolean cache_sim_read_md5sum(FILE *f, gchar *buf, gint s, CacheData *cd)
 {
        if (!f || !buf || !cd) return FALSE;
 
@@ -371,7 +371,7 @@ static gint cache_sim_read_md5sum(FILE *f, gchar *buf, gint s, CacheData *cd)
        return FALSE;
 }
 
-static gint cache_sim_read_similarity(FILE *f, gchar *buf, gint s, CacheData *cd)
+static gboolean cache_sim_read_similarity(FILE *f, gchar *buf, gint s, CacheData *cd)
 {
        if (!f || !buf || !cd) return FALSE;
 
@@ -570,7 +570,7 @@ void cache_sim_data_set_similarity(CacheData *cd, ImageSimilarityData *sd)
        cd->similarity = TRUE;
 }
 
-gint cache_sim_data_filled(ImageSimilarityData *sd)
+gboolean cache_sim_data_filled(ImageSimilarityData *sd)
 {
        if (!sd) return FALSE;
        return sd->filled;
@@ -603,6 +603,11 @@ static void cache_path_parts(CacheType type,
                        *cache_local = GQ_CACHE_LOCAL_METADATA;
                        *cache_ext = GQ_CACHE_EXT_METADATA;
                        break;
+               case CACHE_TYPE_XMP_METADATA:
+                       *cache_rc = get_metadata_cache_dir();
+                       *cache_local = GQ_CACHE_LOCAL_METADATA;
+                       *cache_ext = GQ_CACHE_EXT_XMP_METADATA;
+                       break;
                }
 }
 
@@ -625,8 +630,8 @@ gchar *cache_get_location(CacheType type, const gchar *source, gint include_name
                name = g_strconcat(filename_from_path(source), cache_ext, NULL);
                }
 
-       if (((type != CACHE_TYPE_METADATA && options->thumbnails.cache_into_dirs) ||
-            (type == CACHE_TYPE_METADATA && options->metadata.enable_metadata_dirs)) &&
+       if (((type != CACHE_TYPE_METADATA && type != CACHE_TYPE_XMP_METADATA && options->thumbnails.cache_into_dirs) ||
+            ((type == CACHE_TYPE_METADATA || type == CACHE_TYPE_XMP_METADATA) && options->metadata.enable_metadata_dirs)) &&
            access_file(base, W_OK))
                {
                path = g_build_filename(base, cache_local, name, NULL);
@@ -653,7 +658,7 @@ static gchar *cache_build_path_local(const gchar *source, const gchar *cache_loc
        path = g_build_filename(base, cache_local, name, NULL);
        g_free(name);
        g_free(base);
-       
+
        return path;
 }
 
@@ -673,13 +678,13 @@ gchar *cache_find_location(CacheType type, const gchar *source)
        const gchar *cache_rc;
        const gchar *cache_local;
        const gchar *cache_ext;
-       gint prefer_local;
+       gboolean prefer_local;
 
        if (!source) return NULL;
 
        cache_path_parts(type, &cache_rc, &cache_local, &cache_ext);
 
-       if (type == CACHE_TYPE_METADATA)
+       if (type == CACHE_TYPE_METADATA || type == CACHE_TYPE_XMP_METADATA)
                {
                prefer_local = options->metadata.enable_metadata_dirs;
                }
@@ -721,13 +726,13 @@ gchar *cache_find_location(CacheType type, const gchar *source)
        return path;
 }
 
-gint cache_time_valid(const gchar *cache, const gchar *path)
+gboolean cache_time_valid(const gchar *cache, const gchar *path)
 {
        struct stat cache_st;
        struct stat path_st;
        gchar *cachel;
        gchar *pathl;
-       gint ret = FALSE;
+       gboolean ret = FALSE;
 
        if (!cache || !path) return FALSE;