Internal interfaces in cache management changed again...
return FcFalse;
}
+FcCache *
+FcCacheFileMap (const FcChar8 *file)
+{
+ FcCache *cache;
+ int fd;
+ struct stat file_stat;
+
+ fd = open (file, O_RDONLY | O_BINARY);
+ if (fd < 0)
+ return NULL;
+ if (fstat (fd, &file_stat) < 0) {
+ close (fd);
+ return NULL;
+ }
+ if (FcCacheLoad (fd, file_stat.st_size, &cache)) {
+ close (fd);
+ return cache;
+ }
+ close (fd);
+ return NULL;
+}
+
int
main (int argc, char **argv)
{
for (; i < argc; i++)
{
- int fd;
int j;
off_t size;
intptr_t *cache_dirs;
if (FcFileIsDir ((const FcChar8 *)argv[i]))
- fd = FcDirCacheOpen (config, (const FcChar8 *) argv[i], &size);
+ cache = FcDirCacheMap ((const FcChar8 *) argv[i], config);
else
- fd = FcCacheFileOpen (argv[i], &size);
- if (fd < 0)
+ cache = FcCacheFileMap (argv[i]);
+ if (!cache)
{
perror (argv[i]);
ret++;
continue;
}
- cache = FcDirCacheMap (fd, size);
- close (fd);
- if (!cache)
- {
- fprintf (stderr, "%s: cannot map cache\n", argv[i]);
- ret++;
- continue;
- }
dirs = FcStrSetCreate ();
fs = FcCacheSet (cache);
cache_dirs = FcCacheDirs (cache);
}
static FcBool
-FcDirCacheLoad (int fd, off_t size, void *closure)
+FcCacheLoad (int fd, off_t size, void *closure)
{
FcCache *cache;
FcBool allocated = FcFalse;
}
FcCache *
-FcDirCacheMap (int fd, off_t size)
+FcDirCacheMap (const FcChar8 *dir, FcConfig *config)
{
- FcCache *cache;
+ FcCache *cache = NULL;
- if (FcDirCacheLoad (fd, size, &cache))
- return cache;
- return NULL;
+ if (!FcDirCacheProcess (config, dir,
+ FcCacheLoad,
+ &cache))
+ return NULL;
+ return cache;
}
FcBool
intptr_t *cache_dirs;
FcPattern **cache_fonts;
- if (!FcDirCacheProcess (config, dir,
- FcDirCacheLoad,
- &cache))
+ cache = FcDirCacheMap (dir, config);
+ if (!cache)
return FcFalse;
cache_set = FcCacheSet (cache);
FcDirCacheConsume (FILE *file, FcFontSet *set, FcStrSet *dirs,
const FcChar8 *dir, char *dirname);
-FcCache *
-FcDirCacheMap (int fd, off_t size);
-
void
FcDirCacheUnmap (FcCache *cache);
FcBool
FcDirCacheRead (FcFontSet * set, FcStrSet * dirs, const FcChar8 *dir, FcConfig *config);
+FcCache *
+FcDirCacheMap (const FcChar8 *dir, FcConfig *config);
+
+FcBool
+FcDirCacheLoad (int fd, off_t size, void *closure);
+
/* fccfg.c */
FcBool