summaryrefslogtreecommitdiff
path: root/otfl-luat-dum.lua
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2010-10-14 12:25:43 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2010-10-14 12:25:43 +0200
commit656211fb299687f2de271018b1dc4bcefc76ac9d (patch)
tree9165fe679ac451a2cf5feb5095a507740fe6efe5 /otfl-luat-dum.lua
parent6f9e8865e4759426be87e73c14b3e5d604de8f14 (diff)
downloadluaotfload-656211fb299687f2de271018b1dc4bcefc76ac9d.tar.gz
Make cache directory creation more robust
If the top directories do not exist (in case we were run the first to be run after fresh texlive install) try to make them first. closes #17
Diffstat (limited to 'otfl-luat-dum.lua')
-rw-r--r--otfl-luat-dum.lua24
1 files changed, 13 insertions, 11 deletions
diff --git a/otfl-luat-dum.lua b/otfl-luat-dum.lua
index e8e267a..9607697 100644
--- a/otfl-luat-dum.lua
+++ b/otfl-luat-dum.lua
@@ -92,24 +92,26 @@ end
do
- local cachepaths = kpse.expand_path('$TEXMFCACHE') or ""
+ local cachepaths
- if cachepaths == "" then
- cachepaths = kpse.expand_path('$TEXMFVAR')
+ if kpse.expand_var('$TEXMFCACHE') ~= '$TEXMFCACHE' then
+ cachepaths = kpse.expand_var('$TEXMFCACHE')
+ elseif kpse.expand_var('$TEXMFVAR') ~= '$TEXMFVAR' then
+ cachepaths = kpse.expand_var('$TEXMFVAR')
end
- if cachepaths == "" then
+ if not cachepaths then
cachepaths = "."
end
cachepaths = string.split(cachepaths,os.type == "windows" and ";" or ":")
for i=1,#cachepaths do
- if file.iswritable(cachepaths[i]) then
- writable = file.join(cachepaths[i],"luatex-cache")
- lfs.mkdir(writable)
- writable = file.join(writable,caches.namespace)
- lfs.mkdir(writable)
+ local done
+ writable = file.join(cachepaths[i], "luatex-cache")
+ writable = file.join(writable,caches.namespace)
+ writable, done = dir.mkdirs(writable)
+ if done then
break
end
end
@@ -121,10 +123,10 @@ do
end
if not writable then
- texio.write_nl("quiting: fix your writable cache path")
+ texio.write_nl("quiting: fix your writable cache path\n")
os.exit()
elseif #readables == 0 then
- texio.write_nl("quiting: fix your readable cache path")
+ texio.write_nl("quiting: fix your readable cache path\n")
os.exit()
elseif #readables == 1 and readables[1] == writable then
texio.write(string.format("(using cache: %s)",writable))