static FcBool
FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
FcBool (*callback) (int fd, off_t size, void *closure),
- void *closure)
+ void *closure, FcChar8 **cache_file_ret)
{
int fd = -1;
FcChar8 cache_base[CACHEBASE_LEN];
if (!cache_hashed)
break;
fd = open((char *) cache_hashed, O_RDONLY | O_BINARY);
- FcStrFree (cache_hashed);
if (fd >= 0) {
if (fstat (fd, &file_stat) >= 0 &&
dir_stat.st_mtime <= file_stat.st_mtime)
ret = (*callback) (fd, file_stat.st_size, closure);
if (ret)
{
+ if (cache_file_ret)
+ *cache_file_ret = cache_hashed;
+ else
+ FcStrFree (cache_hashed);
close (fd);
break;
}
}
close (fd);
}
+ FcStrFree (cache_hashed);
}
FcStrListDone (list);
return ret;
}
-static FcBool
-FcCacheLoad (int fd, off_t size, void *closure)
+FcBool
+FcDirCacheLoad (int fd, off_t size, void *closure)
{
FcCache *cache;
FcBool allocated = FcFalse;
}
FcCache *
-FcDirCacheMap (const FcChar8 *dir, FcConfig *config)
+FcDirCacheMap (const FcChar8 *dir, FcConfig *config, FcChar8 **cache_file)
{
FcCache *cache = NULL;
if (!FcDirCacheProcess (config, dir,
- FcCacheLoad,
- &cache))
+ FcDirCacheLoad,
+ &cache, cache_file))
return NULL;
return cache;
}
intptr_t *cache_dirs;
FcPattern **cache_fonts;
- cache = FcDirCacheMap (dir, config);
+ cache = FcDirCacheMap (dir, config, NULL);
if (!cache)
return FcFalse;
return ret;
}
+static FcBool
+FcDirCacheValidConfig (const FcChar8 *dir, FcConfig *config)
+{
+ return FcDirCacheProcess (config, dir, FcDirCacheValidate, NULL, NULL);
+}
+
FcBool
-FcDirCacheValid (const FcChar8 *dir, FcConfig *config)
+FcDirCacheValid (const FcChar8 *dir)
{
- return FcDirCacheProcess (config, dir, FcDirCacheValidate, NULL);
+ FcConfig *config;
+
+ config = FcConfigGetCurrent ();
+ if (!config)
+ return FcFalse;
+
+ return FcDirCacheValidConfig (dir, config);
}
void