1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-23 02:28:05 +11:00

Added the dlfs module, used to download a filesystem from a remote FRequest server to the tmpfs and boot from it. This is used for the nbcore file, which is the actually usable version of that.

This commit is contained in:
Izaya 2019-05-21 02:32:05 +10:00
parent dc4f76fdcb
commit 6cbe2d6479
4 changed files with 57 additions and 2 deletions

36
Embedded/dlfs.lua Normal file
View File

@ -0,0 +1,36 @@
c=""
do
local host,port,FD=component.invoke(component.list("eeprom")(),"getData"):match("(.+)\n(.+)\n(.+)")
port=tonumber(port)
local fs,dirlist,filelist=component.proxy(computer.tmpAddress()),{FD},{}
for _,dir in pairs(dirlist) do
local content,ftype = fget(host,dir,port)
if ftype == "d" then
for line in content:gmatch("[^\n]+") do
if line:sub(-1) == "/" then
dirlist[#dirlist+1] = dir..line
else
filelist[#filelist+1] = dir..line
end
end
end
end
for _,dir in pairs(dirlist) do
dir=dir:sub(#dirlist[1])
fs.makeDirectory(dir)
end
for _,file in pairs(filelist) do
local filename=file:sub(#dirlist[1]+1)
local content,ftype = fget(host,file,port)
f=fs.open(filename,"wb")
fs.write(f,content)
fs.close(f)
end
local fh,b = fs.open("boot.lua"),""
repeat
b=fs.read(fh,4096) or ""
c=c..b
until b == ""
end
computer.getBootAddress = computer.tmpAddress
load(c)()

14
Embedded/dlfs.lua.min Normal file
View File

@ -0,0 +1,14 @@
{
{"init","I"},
{"dirlist","DL"},
{"filelist","FL"},
{"host","H"},
{"port","P"},
{"line","L"},
{"ftype","F"},
{"content","K"},
{"filename","FN"},
{"table.remove","TR"},
{"dir","CD"},
{"file","CF"}
,}

View File

@ -2,9 +2,9 @@ function fget(A,P,V)
local b,tb,s="","",net.open(A,V or 70)
s:w("t"..P.."\n")
repeat
UC.pullSignal()
computer.pullSignal()
tb=s:r(2048)
b=b..tb
until tb == "" and s.s == "c"
return b:sub(2)
return b:sub(2),b:sub(1,1)
end

View File

@ -9,6 +9,8 @@ echo ufs.lua
lua minify.lua ufs.lua mini-ufs.lua
echo init-wrapper.lua
lua minify.lua init-wrapper.lua mini-init-wrapper.lua
echo dlfs.lua
lua minify.lua dlfs.lua mini-dlfs.lua
echo microtel-3.lua
lua minify.lua microtel/microtel-3.lua microtel/mini-microtel-3.lua
echo microtel-4.lua
@ -27,3 +29,6 @@ cat microtel/mini-microtel-{3,4,5-core,5-open}.lua mini-vt100.lua mini-minipromp
lua minify.lua nminiprompt.lua mini-nminiprompt.lua
echo -e "GC,UC=component,computer" | cat - mini-nminiprompt.lua > mini-fnminiprompt.lua
mv mini-fnminiprompt.lua mini-nminiprompt.lua
cat microtel/mini-microtel-{3,4,5-core,5-open}.lua mini-fget.lua mini-dlfs.lua > mini-nbcore.lua
cat microtel/microtel-{3,4,5-core,5-open}.lua fget.lua dlfs.lua > nbcore.lua