+2005-11-02 Patrick Lam <plam@mit.edu>
+ * src/fccache.c (FcGlobalCacheLoad):
+ * src/fccfg.c (FcConfigModifiedTime, FcConfigBuildFonts):
+ * src/fcint.h:
+
+ Declare the global cache of a directory's contents to be stale if
+ the directory is newer than the (newest) configuration file.
+
2005-10-31 Patrick Lam <plam@mit.edu>
* src/fcint.h:
* src/fclist.c (FcListAppend):
void
FcGlobalCacheLoad (FcGlobalCache *cache,
FcStrSet *staleDirs,
- const FcChar8 *cache_file)
+ const FcChar8 *cache_file,
+ FcConfig *config)
{
char name_buf[8192];
FcGlobalCacheDir *d, *next;
+ FcFileTime config_time = FcConfigModifiedTime (config);
char * current_arch_machine_name;
char candidate_arch_machine_name[MACHINE_SIGNATURE_SIZE + 9];
off_t current_arch_start;
if (!strlen(name_buf))
break;
+ /* Directory must be older than the global cache file, and
+ also must be older than the config file. */
if (stat ((char *) name_buf, &dir_stat) < 0 ||
- dir_stat.st_mtime > cache_stat.st_mtime)
+ dir_stat.st_mtime > cache_stat.st_mtime ||
+ (config_time.set && dir_stat.st_mtime > config_time.time))
{
FcCache md;
* If the directory has been modified more recently than
* the cache file, the cache is not valid
*/
- if (dir_stat.st_mtime - file_stat.st_mtime > 0)
+ if (dir_stat.st_mtime > file_stat.st_mtime)
return FcFalse;
+
return FcTrue;
}
return 0;
}
-typedef struct _FcFileTime {
- time_t time;
- FcBool set;
-} FcFileTime;
-
static FcFileTime
FcConfigNewestFile (FcStrSet *files)
{
return newest;
}
+FcFileTime
+FcConfigModifiedTime (FcConfig *config)
+{
+ if (!config)
+ {
+ FcFileTime v = { 0, FcFalse };
+ config = FcConfigGetCurrent ();
+ if (!config)
+ return v;
+ }
+ return FcConfigNewestFile (config->configFiles);
+}
+
FcBool
FcConfigUptoDate (FcConfig *config)
{
goto bail2;
if (config->cache)
- FcGlobalCacheLoad (cache, oldDirs, config->cache);
+ FcGlobalCacheLoad (cache, oldDirs, config->cache, config);
cached_fonts = FcCacheRead(config, cache);
if (!cached_fonts)
extern FcConfig *_fcConfig;
+typedef struct _FcFileTime {
+ time_t time;
+ FcBool set;
+} FcFileTime;
+
typedef struct _FcCharMap FcCharMap;
/* fcblanks.c */
void
FcGlobalCacheLoad (FcGlobalCache *cache,
FcStrSet *staleDirs,
- const FcChar8 *cache_file);
+ const FcChar8 *cache_file,
+ FcConfig *config);
FcBool
FcGlobalCacheUpdate (FcGlobalCache *cache,
FcConfigAcceptFont (FcConfig *config,
const FcPattern *font);
+FcFileTime
+FcConfigModifiedTime (FcConfig *config);
+
/* fccharset.c */
FcCharSet *
FcCharSetFreeze (FcCharSet *cs);