Fix fc-cat again. Sigh.

Internal interfaces in cache management changed again...
This commit is contained in:
Keith Packard 2006-08-30 22:23:25 -07:00
parent 2d3387fd72
commit 76abb77f26
3 changed files with 41 additions and 24 deletions

View File

@ -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);

View File

@ -242,7 +242,7 @@ FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
}
static FcBool
FcDirCacheLoad (int fd, off_t size, void *closure)
FcCacheLoad (int fd, off_t size, void *closure)
{
FcCache *cache;
FcBool allocated = FcFalse;
@ -303,13 +303,15 @@ FcDirCacheLoad (int fd, off_t size, void *closure)
}
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
@ -322,9 +324,8 @@ FcDirCacheRead (FcFontSet * set, FcStrSet * dirs,
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);

View File

@ -500,15 +500,18 @@ FcBool
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