From 58b39788f36a6184714b15a6baad49e22b47f057 Mon Sep 17 00:00:00 2001 From: v Date: Sat, 2 Jan 2021 14:58:12 +0000 Subject: [PATCH] add multifile thing? --- multifile/lib/multifile.lua | 22 ++++++++++++++++++++++ multifile/pkgmeta.ltn | 12 ++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 multifile/lib/multifile.lua create mode 100644 multifile/pkgmeta.ltn diff --git a/multifile/lib/multifile.lua b/multifile/lib/multifile.lua new file mode 100644 index 0000000..51955e7 --- /dev/null +++ b/multifile/lib/multifile.lua @@ -0,0 +1,22 @@ +local mfs=dofile "/lib/mfs.lua" +local res={} + +function res.pack(filename,pf) + if not pf then + pf=filename + filename="" + end + local res2="" + if mfs.type(pf.."/"..filename)=="directory" then + res2=res2.."if not fs.exists('"..filename.."') then fs.makeDir('"..filename.."') end " + local l=fs.list(pf.."/"..filename) + for i,v in ipairs(l) do + res2=res2..res.pack(filename.."/"..v,pf) + end + else + res2=res2.."f=fs.open('"..filename.."','w') f.write("..("%q"):format(mfs.read(pf.."/"..filename))..") f.close() " + end + return res2 +end + +return res diff --git a/multifile/pkgmeta.ltn b/multifile/pkgmeta.ltn new file mode 100644 index 0000000..8327cd5 --- /dev/null +++ b/multifile/pkgmeta.ltn @@ -0,0 +1,12 @@ +{ + ["version"] = "0.1.0", + ["dependencies"] = { + "mfs", + }, + ["description"] = "Packs multiple files into one. Currently only a library", + ["files"] = { + ["lib"] = { + "multifile.lua" + } + } +}