From 656211fb299687f2de271018b1dc4bcefc76ac9d Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Thu, 14 Oct 2010 12:25:43 +0200 Subject: 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 --- otfl-luat-dum.lua | 24 +++++++++++++----------- 1 file 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)) -- cgit v1.2.3