summaryrefslogtreecommitdiff
path: root/fc-cat
diff options
context:
space:
mode:
authorKeith Packard <keithp@neko.keithp.com>2006-08-30 22:23:25 -0700
committerKeith Packard <keithp@neko.keithp.com>2006-08-30 22:23:25 -0700
commit76abb77f26c43d069919f80e960c71c2242fb5c2 (patch)
treea38c75c4fd040d4a2866f6e76aa87a2ed51dee49 /fc-cat
parent2d3387fd720f33f80847ae6cbb83d94c9a52fde3 (diff)
Fix fc-cat again. Sigh.
Internal interfaces in cache management changed again...
Diffstat (limited to 'fc-cat')
-rw-r--r--fc-cat/fc-cat.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c
index b988a293..c033bdc7 100644
--- a/fc-cat/fc-cat.c
+++ b/fc-cat/fc-cat.c
@@ -273,6 +273,28 @@ bail2:
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)
{
@@ -322,30 +344,21 @@ 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);