Update disklock.lua
This commit is contained in:
16
disklock.lua
16
disklock.lua
@@ -28,13 +28,14 @@ local function deepcopy(o, seen)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local realfs = deepcopy(fs)
|
local realfs = deepcopy(fs)
|
||||||
local function getRom(path)
|
local rom_cache = nil
|
||||||
if not path then path = "/rom" end
|
|
||||||
|
local function buildRom(path)
|
||||||
local out = {}
|
local out = {}
|
||||||
for _, file in ipairs(realfs.list(path)) do
|
for _, file in ipairs(realfs.list(path)) do
|
||||||
local fullPath = realfs.combine(path, file) -- use realfs here to avoid recursing into _G.fs
|
local fullPath = realfs.combine(path, file)
|
||||||
if realfs.isDir(fullPath) then
|
if realfs.isDir(fullPath) then
|
||||||
out[file] = getRom(fullPath)
|
out[file] = buildRom(fullPath)
|
||||||
else
|
else
|
||||||
local handle = realfs.open(fullPath, "r")
|
local handle = realfs.open(fullPath, "r")
|
||||||
out[file] = handle.readAll()
|
out[file] = handle.readAll()
|
||||||
@@ -44,6 +45,13 @@ local function getRom(path)
|
|||||||
return out
|
return out
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function getRom()
|
||||||
|
if not rom_cache then
|
||||||
|
rom_cache = buildRom("/rom")
|
||||||
|
end
|
||||||
|
return rom_cache
|
||||||
|
end
|
||||||
|
|
||||||
local function getFileSystem()
|
local function getFileSystem()
|
||||||
if filesystem then filesystem.rom = getRom() return filesystem end
|
if filesystem then filesystem.rom = getRom() return filesystem end
|
||||||
if not realfs.exists("fs") then
|
if not realfs.exists("fs") then
|
||||||
|
|||||||
Reference in New Issue
Block a user