From ec22f80a4df73c67f9a4bfb128ee5065261cc452 Mon Sep 17 00:00:00 2001
From: Philipp Gesang <phg42.2a@gmail.com>
Date: Fri, 10 May 2013 02:29:22 +0200
Subject: create $TEXMFVAR if missing

---
 luaotfload.dtx | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

(limited to 'luaotfload.dtx')

diff --git a/luaotfload.dtx b/luaotfload.dtx
index daaa48c..0d062a6 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -1289,6 +1289,23 @@ if tex.luatexversion < luatex_version then
              luatex_version   /100)
 end
 
+%    \end{macrocode}
+%   Prepare directories: the cache function in Luatex-Fonts checks for a
+%   writable directory only once during startup. If there is no
+%   \fileent{texmf-var} at this time it will create a subdirectory
+%   \fileent{./luatex-cache} instead.
+%   Thus everything has to be laid out before we load the fontloader.
+%
+%    \begin{macrocode}
+
+local cachepath = kpse.expand_var"$TEXMFVAR"
+if not lfs.isdir(cachepath) then
+    dir.mkdirs(cachepath)
+    if not lfs.isdir(cachepath) then
+        error( "ERROR could not create directory %s", cachepath)
+    end
+end
+
 %    \end{macrocode}
 % \subsection{Module loading}
 % We load the files imported from \CONTEXT with this function.
-- 
cgit v1.2.3

