read schematic files from web
This commit is contained in:
@@ -292,7 +292,6 @@ function MemoryFile:write(b)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Schematic:decompress(ifname, spinner)
|
function Schematic:decompress(ifname, spinner)
|
||||||
|
|
||||||
local ifh = fs.open(ifname, "rb")
|
local ifh = fs.open(ifname, "rb")
|
||||||
if not ifh then
|
if not ifh then
|
||||||
error('Unable to open ' .. ifname)
|
error('Unable to open ' .. ifname)
|
||||||
@@ -314,7 +313,6 @@ function Schematic:decompress(ifname, spinner)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Schematic:loadpass(fh, spinner)
|
function Schematic:loadpass(fh, spinner)
|
||||||
|
|
||||||
fh:open()
|
fh:open()
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
@@ -370,7 +368,30 @@ function Schematic:load(filename)
|
|||||||
})
|
})
|
||||||
local f
|
local f
|
||||||
|
|
||||||
if self:isCompressed(filename) then
|
if filename:match("^(https?:)") then
|
||||||
|
local c, msg = Util.httpGet(filename, nil, true)
|
||||||
|
if not c then
|
||||||
|
error(msg)
|
||||||
|
end
|
||||||
|
f = MemoryFile()
|
||||||
|
|
||||||
|
local i = 0
|
||||||
|
local sz = #c
|
||||||
|
DEFLATE.gunzip({
|
||||||
|
input=function()
|
||||||
|
spinner:spin()
|
||||||
|
if i < sz then
|
||||||
|
i = i + 1
|
||||||
|
return c:byte(i)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
output=function(b) f:write(b) end,
|
||||||
|
disable_crc=true
|
||||||
|
})
|
||||||
|
|
||||||
|
spinner:stop()
|
||||||
|
|
||||||
|
elseif self:isCompressed(filename) then
|
||||||
local originalFile = filename
|
local originalFile = filename
|
||||||
filename = originalFile .. '.uncompressed'
|
filename = originalFile .. '.uncompressed'
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,26 @@ local Util = require('util')
|
|||||||
local device = _G.device
|
local device = _G.device
|
||||||
local fs = _G.fs
|
local fs = _G.fs
|
||||||
|
|
||||||
local Syntax = [[Required:
|
local function Syntax(msg)
|
||||||
|
print([[Required:
|
||||||
* Neural Interface
|
* Neural Interface
|
||||||
* Overlay glasses
|
* Overlay glasses
|
||||||
* Entity sensor
|
* Entity sensor
|
||||||
* Introspection module
|
* Introspection module
|
||||||
]]
|
]])
|
||||||
local neural = device['neuralInterface'] or error(Syntax)
|
error(msg)
|
||||||
assert(neural.hasModule('plethora:glasses'), Syntax)
|
end
|
||||||
assert(neural.hasModule("plethora:sensor"), Syntax)
|
|
||||||
assert(neural.hasModule('plethora:introspection'), Syntax)
|
local neural = device['neuralInterface'] or Syntax('Must be run on a neural interface')
|
||||||
|
|
||||||
|
local function assertModule(module, name)
|
||||||
|
if not neural.hasModule(module) then
|
||||||
|
Syntax('Missing: ' .. name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assertModule('plethora:glasses', 'Overlay glasses')
|
||||||
|
assertModule('plethora:sensor', 'Entity sensor')
|
||||||
|
assertModule('plethora:introspection', 'Introspection module')
|
||||||
|
|
||||||
local BUILDER_DIR = 'usr/builder'
|
local BUILDER_DIR = 'usr/builder'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user