From 12784aa92e433fced8885ebd9dc12f3ac5945ab7 Mon Sep 17 00:00:00 2001 From: Justus Wolff Date: Wed, 11 Mar 2026 18:11:57 +0100 Subject: [PATCH] list functionality that is not even finished XD --- main.lua | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ startup.lua | 3 ++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/main.lua b/main.lua index e69de29..8ba7c70 100644 --- a/main.lua +++ b/main.lua @@ -0,0 +1,53 @@ +-- http://justus.l--n.de:3000/JUFS/MDB/raw/branch/main/main.lua +-- or use bootstrapper +print("Copyright JUFS Technologies aka. Justus Wolff 2026") +print("MDB - Multi disk Data Base") +print("init API") + +local API = {} +function API.getDisks() + local disks = {peripheral.find("drive")} + local out = {} + for _,v in pairs(disks) do + if v.isDiskPresent() and v.hasData() then table.insert(out, v.getMountPath()) end + end + return out +end +function API._builtCandidateTree(...) + local path = {...} + local candidates = {} + for _,v in pairs(API.getDisks()) do + table.insert(candidates, fs.combine(v, fs.list(v))) + end + + for _,v in pairs(path) do + local temp = {} + for _,cc in pairs(candidates) do + if fs.getName(cc) == v then + table.insert(temp, cc) + end + end + candidates = temp + end + + return candidates +end +function API.list(...) + local final = {} + for _,v in pairs(API._builtCandidateTree(...)) do + table.insert(final, fs.list(v)) + end + return final +end + +print("Disks: ") +local disks = API.getDisks() +for _,v in pairs(disks) do + print(v..": "..tostring(fs.getFreeSpace()).."/"..tostring(fs.getCapacity())) +end + +for _,v in pairs(API.list()) do + print(v) +end + +return API \ No newline at end of file diff --git a/startup.lua b/startup.lua index 6ea470d..51fe60f 100644 --- a/startup.lua +++ b/startup.lua @@ -1,2 +1,3 @@ --- +-- http://justus.l--n.de:3000/JUFS/MDB/raw/branch/main/startup.lua -- bootstrapper +shell.run("wget run http://justus.l--n.de:3000/JUFS/MDB/raw/branch/main/main.lua")