aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/fc-cache
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
committermarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
commit0f834b91a4768673833ab4917e87d86c237bb1a6 (patch)
tree363489504ed4b2d360259b8de4c9e392918e5d02 /fontconfig/fc-cache
parentfc72edebf875378459368c5383d9023730cbca54 (diff)
downloadvcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'fontconfig/fc-cache')
-rw-r--r--fontconfig/fc-cache/Makefile.am10
-rw-r--r--fontconfig/fc-cache/fc-cache.c81
2 files changed, 84 insertions, 7 deletions
diff --git a/fontconfig/fc-cache/Makefile.am b/fontconfig/fc-cache/Makefile.am
index b647c3f4b..8f455c8e2 100644
--- a/fontconfig/fc-cache/Makefile.am
+++ b/fontconfig/fc-cache/Makefile.am
@@ -33,7 +33,7 @@ install-data-local:
-$(mkinstalldirs) "$(DESTDIR)$(fc_cachedir)"
uninstall-local:
- -rm -rf "$(DESTDIR)$(fc_cachedir)"
+ -$(RM) -rf "$(DESTDIR)$(fc_cachedir)"
endif
INCLUDES=-I${top_srcdir} -I${top_srcdir}/src $(WARN_CFLAGS)
@@ -53,14 +53,14 @@ fc_cache_LDADD = ${top_builddir}/src/libfontconfig.la
if USEDOCBOOK
${man_MANS}: ${SGML}
- -@rm $@
- $(AM_V_GEN) $(DOC2MAN) ${SGML}
- @rm -f manpage.*
+ $(AM_V_GEN) $(RM) $@; \
+ $(DOC2MAN) ${SGML}; \
+ $(RM) manpage.*
all-local: $(man_MANS)
clean-local:
- -rm $(man_MANS)
+ $(RM) $(man_MANS)
else
all-local:
diff --git a/fontconfig/fc-cache/fc-cache.c b/fontconfig/fc-cache/fc-cache.c
index d2653507e..24bb2ec9f 100644
--- a/fontconfig/fc-cache/fc-cache.c
+++ b/fontconfig/fc-cache/fc-cache.c
@@ -22,8 +22,6 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-#include "../src/fcarch.h"
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#else
@@ -34,6 +32,7 @@
#endif
#include <fontconfig/fontconfig.h>
+#include "../src/fcarch.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -44,6 +43,14 @@
#include <dirent.h>
#include <string.h>
+#ifndef FC_DIR_SEPARATOR_S
+# ifdef _WIN32
+# define FC_DIR_SEPARATOR_S "\\"
+# else
+# define FC_DIR_SEPARATOR_S "/"
+# endif
+#endif
+
#if defined (_WIN32)
#define STRICT
#include <windows.h>
@@ -116,6 +123,69 @@ usage (char *program, int error)
static FcStrSet *processed_dirs;
+/* Create CACHEDIR.TAG */
+static FcBool
+create_tag_file (FcConfig *config, FcBool verbose)
+{
+ FcChar8 *cache_tag;
+ FcChar8 *cache_dir = NULL;
+ FcStrList *list;
+ 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 = FcTrue;
+
+ list = FcConfigGetCacheDirs(config);
+ if (!list)
+ return FcFalse;
+
+ while ((cache_dir = FcStrListNext (list)))
+ {
+ if (access ((char *) cache_dir, W_OK|X_OK) == 0)
+ {
+ if (verbose)
+ printf ("Create CACHEDIR.TAG at %s\n", cache_dir);
+ /* 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;
+
+ bail3:
+ FcAtomicUnlock (atomic);
+ bail2:
+ FcAtomicDestroy (atomic);
+ bail1:
+ FcStrFree (cache_tag);
+ }
+ }
+ FcStrListDone (list);
+
+ return ret;
+}
+
static int
scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcBool verbose, int *changed)
{
@@ -451,6 +521,13 @@ main (int argc, char **argv)
changed = 0;
ret = scanDirs (list, config, force, really_force, verbose, &changed);
+ /*
+ * Try to create CACHEDIR.TAG anyway.
+ * This expects the fontconfig cache directory already exists.
+ * If it doesn't, it won't be simply created.
+ */
+ create_tag_file (config, verbose);
+
FcStrSetDestroy (processed_dirs);
cleanCacheDirectories (config, verbose);