]> git.wh0rd.org - fontconfig.git/blobdiff - fc-cat/fc-cat.c
fc-cache: add a --root option
[fontconfig.git] / fc-cat / fc-cat.c
index c6c399343de4aed651f1ce4f7dca2824299b5a71..8d19c615433737ac9808a2d190f0e795e5226334 100644 (file)
@@ -194,11 +194,9 @@ file_base_name (const FcChar8 *cache, const FcChar8 *file)
 static FcBool
 cache_print_set (FcFontSet *set, FcStrSet *dirs, const FcChar8 *base_name, FcBool verbose)
 {
-    FcChar8        *name, *dir;
-    const FcChar8   *file, *base;
-    int                    ret;
+    FcChar8        *dir;
+    const FcChar8   *base;
     int                    n;
-    int                    id;
     int                    ndir = 0;
     FcStrList      *list;
 
@@ -227,37 +225,22 @@ cache_print_set (FcFontSet *set, FcStrSet *dirs, const FcChar8 *base_name, FcBoo
     for (n = 0; n < set->nfont; n++)
     {
        FcPattern   *font = set->fonts[n];
+       FcChar8 *s;
 
-       if (FcPatternGetString (font, FC_FILE, 0, (FcChar8 **) &file) != FcResultMatch)
-           goto bail3;
-       base = file_base_name (base_name, file);
-       if (FcPatternGetInteger (font, FC_INDEX, 0, &id) != FcResultMatch)
-           goto bail3;
-       if (!write_string (stdout, base))
-           goto bail3;
-       if (PUTC (' ', stdout) == EOF)
-           goto bail3;
-       if (!write_int (stdout, id))
-           goto bail3;
-        if (PUTC (' ', stdout) == EOF)
-           goto bail3;
-       name = FcNameUnparse (font);
-       if (!name)
-           goto bail3;
-       ret = write_string (stdout, name);
-       FcStrFree (name);
-       if (!ret)
-           goto bail3;
-       if (PUTC ('\n', stdout) == EOF)
-           goto bail3;
+       s = FcPatternFormat (font, (const FcChar8 *) "%{=fccat}\n");
+       if (s)
+       {
+           printf ("%s", s);
+           free (s);
+       }
     }
     if (verbose && !set->nfont && !ndir)
        printf ("<empty>\n");
-    
+
     FcStrListDone (list);
 
     return FcTrue;
-    
+
 bail3:
     FcStrListDone (list);
 bail2:
@@ -366,10 +349,10 @@ main (int argc, char **argv)
        FcChar8     *cache_file = NULL;
        struct stat file_stat;
        
-       if (FcFileIsDir (arg))
+       if (FcFileIsDir2 (config, arg))
            cache = FcDirCacheLoad (arg, config, &cache_file);
        else
-           cache = FcDirCacheLoadFile (arg, &file_stat);
+           cache = FcDirCacheLoadFile2 (arg, config, &file_stat);
        if (!cache)
        {
            perror ((char *) arg);