list functionality that is not even finished XD

This commit is contained in:
Justus Wolff
2026-03-11 18:11:57 +01:00
parent 4e28f393e9
commit 12784aa92e
2 changed files with 55 additions and 1 deletions

View File

@@ -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

View File

@@ -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")