diff options
author | marha <marha@users.sourceforge.net> | 2012-04-23 14:53:52 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-04-23 14:53:52 +0200 |
commit | cd27f58626705bcb561115b8e5b0d1430df83fa6 (patch) | |
tree | 0fea00b96d0cb4a9d55bd0792e5b4634c78864d6 /fontconfig/src | |
parent | 588abfd54eb267dd79fe441e42aee9fc7534eb6e (diff) | |
parent | b68922d51f52ca6ab9daa0105ef5c57f35bfbdcf (diff) | |
download | vcxsrv-cd27f58626705bcb561115b8e5b0d1430df83fa6.tar.gz vcxsrv-cd27f58626705bcb561115b8e5b0d1430df83fa6.tar.bz2 vcxsrv-cd27f58626705bcb561115b8e5b0d1430df83fa6.zip |
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'fontconfig/src')
-rw-r--r-- | fontconfig/src/fccache.c | 85 | ||||
-rw-r--r-- | fontconfig/src/fccfg.c | 2 | ||||
-rw-r--r-- | fontconfig/src/fcint.h | 3 | ||||
-rw-r--r-- | fontconfig/src/fcstr.c | 2 |
4 files changed, 90 insertions, 2 deletions
diff --git a/fontconfig/src/fccache.c b/fontconfig/src/fccache.c index d3842ddff..d1fa7783b 100644 --- a/fontconfig/src/fccache.c +++ b/fontconfig/src/fccache.c @@ -931,6 +931,8 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config) if (FcMakeDirectory (test_dir)) { cache_dir = test_dir; + /* Create CACHEDIR.TAG */ + FcDirCacheCreateTagFile (cache_dir); break; } } @@ -940,6 +942,8 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config) else if (chmod ((char *) test_dir, 0755) == 0) { cache_dir = test_dir; + /* Try to create CACHEDIR.TAG too */ + FcDirCacheCreateTagFile (cache_dir); break; } } @@ -1409,6 +1413,87 @@ static void MD5Transform(FcChar32 buf[4], FcChar32 in[16]) buf[2] += c; buf[3] += d; } + +FcBool +FcDirCacheCreateTagFile (const FcChar8 *cache_dir) +{ + FcChar8 *cache_tag; + int fd; + FILE *fp; + FcAtomic *atomic; + static const FcChar8 cache_tag_contents[] = + "Signature: 8a477f597d28d172789f06886806bc55\n" + "# This file is a cache directory tag created by fontconfig.\n" + "# For information about cache directory tags, see:\n" + "# http://www.brynosaurus.com/cachedir/\n"; + static size_t cache_tag_contents_size = sizeof (cache_tag_contents) - 1; + FcBool ret = FcFalse; + + if (!cache_dir) + return FcFalse; + + if (access ((char *) cache_dir, W_OK|X_OK) == 0) + { + /* Create CACHEDIR.TAG */ + cache_tag = FcStrPlus (cache_dir, (const FcChar8 *) FC_DIR_SEPARATOR_S "CACHEDIR.TAG"); + if (!cache_tag) + return FcFalse; + atomic = FcAtomicCreate ((FcChar8 *)cache_tag); + if (!atomic) + goto bail1; + if (!FcAtomicLock (atomic)) + goto bail2; + fd = open((char *)FcAtomicNewFile (atomic), O_RDWR | O_CREAT, 0644); + if (fd == -1) + goto bail3; + fp = fdopen(fd, "wb"); + if (fp == NULL) + goto bail3; + + fwrite(cache_tag_contents, cache_tag_contents_size, sizeof (FcChar8), fp); + fclose(fp); + + if (!FcAtomicReplaceOrig(atomic)) + goto bail3; + + ret = FcTrue; + bail3: + FcAtomicUnlock (atomic); + bail2: + FcAtomicDestroy (atomic); + bail1: + FcStrFree (cache_tag); + } + + if (FcDebug () & FC_DBG_CACHE) + { + if (ret) + printf ("Created CACHEDIR.TAG at %s\n", cache_dir); + else + printf ("Unable to create CACHEDIR.TAG at %s\n", cache_dir); + } + + return ret; +} + +void +FcCacheCreateTagFile (const FcConfig *config) +{ + FcChar8 *cache_dir = NULL; + FcStrList *list; + + list = FcConfigGetCacheDirs (config); + if (!list) + return; + + while ((cache_dir = FcStrListNext (list))) + { + if (FcDirCacheCreateTagFile (cache_dir)) + break; + } + FcStrListDone (list); +} + #define __fccache__ #include "fcaliastail.h" #undef __fccache__ diff --git a/fontconfig/src/fccfg.c b/fontconfig/src/fccfg.c index bd1dc34d7..0d0b778d2 100644 --- a/fontconfig/src/fccfg.c +++ b/fontconfig/src/fccfg.c @@ -471,7 +471,7 @@ FcConfigAddCacheDir (FcConfig *config, } FcStrList * -FcConfigGetCacheDirs (FcConfig *config) +FcConfigGetCacheDirs (const FcConfig *config) { if (!config) { diff --git a/fontconfig/src/fcint.h b/fontconfig/src/fcint.h index 1e39fecd1..e45df5351 100644 --- a/fontconfig/src/fcint.h +++ b/fontconfig/src/fcint.h @@ -544,6 +544,9 @@ FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, struct stat *dir_stat, FcSt FcPrivate FcBool FcDirCacheWrite (FcCache *cache, FcConfig *config); +FcPrivate FcBool +FcDirCacheCreateTagFile (const FcChar8 *cache_dir); + FcPrivate void FcCacheObjectReference (void *object); diff --git a/fontconfig/src/fcstr.c b/fontconfig/src/fcstr.c index a6f0ba766..ae37ff00a 100644 --- a/fontconfig/src/fcstr.c +++ b/fontconfig/src/fcstr.c @@ -306,7 +306,7 @@ _FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex, int cflags, int eflags) return ret == 0 ? FcTrue : FcFalse; } #else -# define _FcStrRegexCmp(_s_, _regex_) (FcFalse) +# define _FcStrRegexCmp(_s_, _regex_, _cflags_, _eflags_) (FcFalse) #endif FcBool |