+
+bail2:
+ FcStrSetDestroy (files);
+bail1:
+ closedir (d);
+bail:
+ if (file)
+ free (file);
+
+ return ret;
+}
+
+FcBool
+FcDirScan (FcFontSet *set,
+ FcStrSet *dirs,
+ FcFileCache *cache, /* XXX unused */
+ FcBlanks *blanks,
+ const FcChar8 *dir,
+ FcBool force /* XXX unused */)
+{
+ if (cache || !force)
+ return FcFalse;
+
+ return FcDirScanConfig (set, dirs, blanks, dir, force, FcConfigGetCurrent ());
+}
+
+/*
+ * Scan the specified directory and construct a cache of its contents
+ */
+FcCache *
+FcDirCacheScan (const FcChar8 *dir, FcConfig *config)
+{
+ FcStrSet *dirs;
+ FcFontSet *set;
+ FcCache *cache = NULL;
+ struct stat dir_stat;
+ const FcChar8 *sysroot = FcConfigGetSysRoot (config);
+ FcChar8 *d;
+ int fd = -1;
+
+ if (sysroot)
+ d = FcStrBuildFilename (sysroot, dir, NULL);
+ else
+ d = FcStrdup (dir);
+
+ if (FcDebug () & FC_DBG_FONTSET)
+ printf ("cache scan dir %s\n", d);
+
+ if (FcStatChecksum (d, &dir_stat) < 0)
+ goto bail;
+
+ set = FcFontSetCreate();
+ if (!set)
+ goto bail;
+
+ dirs = FcStrSetCreateEx (FCSS_GROW_BY_64);
+ if (!dirs)
+ goto bail1;
+
+ fd = FcDirCacheLock (dir, config);
+ /*
+ * Scan the dir
+ */
+ if (!FcDirScanConfig (set, dirs, NULL, d, FcTrue, config))
+ goto bail2;
+