+static FcBool
+FcDirCacheValidate (int fd, off_t size, void *closure)
+{
+ FcBool ret = FcTrue;
+ FcCache c;
+ struct stat file_stat;
+
+ if (read (fd, &c, sizeof (FcCache)) != sizeof (FcCache))
+ ret = FcFalse;
+ else if (fstat (fd, &file_stat) < 0)
+ ret = FcFalse;
+ else if (c.magic != FC_CACHE_MAGIC)
+ ret = FcFalse;
+ else if (file_stat.st_size != c.size)
+ ret = FcFalse;
+ return ret;
+}
+
+FcBool
+FcDirCacheValid (const FcChar8 *dir, FcConfig *config)
+{
+ return FcDirCacheProcess (config, dir, FcDirCacheValidate, NULL);
+}
+
+void
+FcDirCacheUnmap (FcCache *cache)
+{
+ if (cache->magic == FC_CACHE_MAGIC_COPY)
+ {
+ free (cache);
+ return;
+ }
+#if defined(HAVE_MMAP) || defined(__CYGWIN__)
+ munmap (cache, cache->size);
+#elif defined(_WIN32)
+ UnmapViewOfFile (cache);
+#endif
+}
+