mirror of
https://github.com/Adorable-Catgirl/Zorya-NEO.git
synced 2024-11-23 10:48:06 +11:00
Stuff^2
This commit is contained in:
parent
2a778b976f
commit
90f1537fa4
@ -1,14 +1,14 @@
|
||||
local readfile=function(f,h)
|
||||
local b=""
|
||||
local d,r=component.invoke(f,"read",h,math.huge)
|
||||
local d,r=f.read(h,math.huge)
|
||||
if not d and r then error(r)end
|
||||
b=d
|
||||
while d do
|
||||
local d,r=component.invoke(f,"read",h,math.huge)
|
||||
local d,r=f.read(h,math.huge)
|
||||
b=b..(d or "")
|
||||
if(not d)then break end
|
||||
end
|
||||
component.invoke(f,"close",h)
|
||||
f.close(h)
|
||||
return b
|
||||
end
|
||||
|
||||
@ -17,15 +17,30 @@ local bfs = {}
|
||||
local cfg = component.proxy(component.list("eeprom")()).getData()
|
||||
|
||||
local baddr = cfg:sub(1, 36)
|
||||
local bootfs = component.proxy(baddr)
|
||||
|
||||
local romfs_file = component.invoke(baddr, "open", ".zy2/bootimage.romfs")
|
||||
|
||||
local romfs_dev = romfs.read(function(a)
|
||||
return bootfs.read(romfs_file, a)
|
||||
end, function(a)
|
||||
return bootfs.seek(romfs_file, "cur", a)
|
||||
end, function()
|
||||
return bootfs.close(romfs_file)
|
||||
end)
|
||||
|
||||
function bfs.getfile(path)
|
||||
local h = assert(component.invoke(baddr, "open", path, "r"))
|
||||
return readfile(baddr, h)
|
||||
return romfs_dev:fetch(path)
|
||||
end
|
||||
|
||||
function bfs.exists(path)
|
||||
return component.invoke(baddr, "exists", path)
|
||||
return romfs_dev:exists(path)
|
||||
end
|
||||
|
||||
function bfs.getcfg()
|
||||
local h = assert(bootfs.open(".zy2/cfg.lua", "r"))
|
||||
readfile(bootfs, h)
|
||||
return
|
||||
end
|
||||
|
||||
bfs.addr = baddr
|
@ -30,6 +30,15 @@ function arc:fetch(path)
|
||||
return nil, "file not found"
|
||||
end
|
||||
|
||||
function arc:exists(path)
|
||||
for i=1, #self.tbl do
|
||||
if (self.tbl[i].name == path) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function arc:close()
|
||||
self.close()
|
||||
self.tbl = nil
|
||||
@ -47,6 +56,4 @@ function arc:list_dir(path)
|
||||
end
|
||||
end
|
||||
return ent
|
||||
end
|
||||
|
||||
return romfs
|
||||
end
|
@ -32,6 +32,8 @@ end
|
||||
local builtins = {}
|
||||
--#include "src/zy-neo/utils.lua"
|
||||
|
||||
--#include "src/zy-neo/builtins/util_romfs.lua"
|
||||
|
||||
sys.add_lib("zorya", (function()
|
||||
|
||||
local mod_search = {}
|
||||
@ -48,9 +50,7 @@ sys.add_lib("zorya", (function()
|
||||
|
||||
local loaded_mods = {}
|
||||
|
||||
loaded_mods.util_romfs = (function()
|
||||
--#include "src/zy-neo/builtins/util_romfs.lua"
|
||||
end)()
|
||||
loaded_mods.util_romfs = romfs
|
||||
|
||||
function zy.loadmod(mod)
|
||||
if (loaded_mods[mod]) then return loaded_mods[mod] end
|
||||
|
@ -90,12 +90,6 @@ function setBar(pos)
|
||||
computer.pullSignal(0)
|
||||
end
|
||||
|
||||
function writeFile(fs, path, data)
|
||||
local hand = fs.open(path, "w")
|
||||
fs.write(hand, data)
|
||||
fs.close(hand)
|
||||
end
|
||||
|
||||
function mkdir(fs, path)
|
||||
fs.makeDirectory(path)
|
||||
end
|
||||
@ -108,6 +102,24 @@ fs.makeDirectory(".zy2")
|
||||
fs.makeDirectory(".zy2/mods")
|
||||
fs.makeDirectory(".zy2/lib")
|
||||
|
||||
local romfs = fs.open(".zy2/image.romfs", "w")
|
||||
fs.write(romfs, "romfs\1\0")
|
||||
|
||||
function writeFile(path, data)
|
||||
--local hand = fs.open(path, "w")
|
||||
--fs.write(hand, data)
|
||||
--fs.close(hand)
|
||||
fs.write(romfs, string.char(#path)..path)
|
||||
local ext = path:sub(#path-2)
|
||||
if (ext == "lua" or ext == "z2l" or ext == "z2y") then
|
||||
fs.write(romfs, "x")
|
||||
else
|
||||
fs.write(romfs, "-")
|
||||
end
|
||||
fs.write(romfs, string.pack("<i2", #data))
|
||||
fs.write(romfs, data)
|
||||
end
|
||||
|
||||
setStatus("Getting file list...")
|
||||
setBar(0)
|
||||
local bios_files = load("return "..getfile("installer_dat/bios_list.lua"))()
|
||||
@ -122,9 +134,11 @@ setBar(0)
|
||||
for i=1, #pkg_files do
|
||||
setStatus("Extracting "..(lang["mod_"..pkg_files[i].cat.."_"..pkg_files[i].name.."_name"] or "#mod_"..pkg_files[i].cat.."_"..pkg_files[i].name.."_name").."... ("..i.." of "..#pkg_files..")")
|
||||
setBar(100*(i/#pkg_files))
|
||||
writeFile(fs, ".zy2/"..pkg_files[i].path, getfile(pkg_files[i].path))
|
||||
writeFile(".zy2/"..pkg_files[i].path, getfile(pkg_files[i].path))
|
||||
end
|
||||
|
||||
writeFile("TRAILER!!!", [[{os="Zorya NEO",version="2.0"}]])
|
||||
|
||||
setStatus("Extracting EEPROM...")
|
||||
setBar(0)
|
||||
local bios = getfile(bios_files[1].path)
|
||||
|
Loading…
Reference in New Issue
Block a user