Fwd: Importing .tex files using \directlua to navigate files and folders
-------- Forwarded Message --------
Subject: Re: [Dev-luatex] Importing .tex files using \directlua to
navigate files and folders
Date: Fri, 12 Aug 2022 09:44:24 +0200
From: Hans Hagen
On 11 Aug 2022, at 14:08, paolo de luca
wrote: Hi all,
I've been trying to import all tex files and inside a given folder, the issue I'm facing is that my lua call is not able to navigate folders: it only works for files. It's worth mentioning that compilation successfully completes as the document is created, but I have no errors explaining me why it's not working as intended. I've also opened a question on tex.stackexchange.
would you mind having a look at it ?
https://tex.stackexchange.com/questions/653499/understanding-implicit-error-...
See comment on SX. Don't 'return' the nested call, and it works just fine.
function inputAll(dir) for content in lfs.dir(dir) do if ("." ~= content) and (".." ~= content) then fullpath = dir .."/".. content contentType = lfs.attributes(fullpath, "mode") if isTexFile(content, contentType) then tex.sprint(" \\ input{" .. fullpath .. "}") elseif ("directory" == contentType) then -- return inputAll(fullpath) end end end end
yes, the return is quitter, but even then one can run into some nested directory handle issue especially when one does things inside that loop on one of the directories (maybe the \input results in new files there or files get deleted and or ..) and one wants to have a predictable sorted list i assume so i tend to collect first Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (1)
-
Hans Hagen