read schematic files from web
This commit is contained in:
@@ -292,7 +292,6 @@ function MemoryFile:write(b)
|
||||
end
|
||||
|
||||
function Schematic:decompress(ifname, spinner)
|
||||
|
||||
local ifh = fs.open(ifname, "rb")
|
||||
if not ifh then
|
||||
error('Unable to open ' .. ifname)
|
||||
@@ -314,7 +313,6 @@ function Schematic:decompress(ifname, spinner)
|
||||
end
|
||||
|
||||
function Schematic:loadpass(fh, spinner)
|
||||
|
||||
fh:open()
|
||||
|
||||
while true do
|
||||
@@ -370,7 +368,30 @@ function Schematic:load(filename)
|
||||
})
|
||||
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
|
||||
filename = originalFile .. '.uncompressed'
|
||||
|
||||
|
||||
@@ -6,16 +6,26 @@ local Util = require('util')
|
||||
local device = _G.device
|
||||
local fs = _G.fs
|
||||
|
||||
local Syntax = [[Required:
|
||||
local function Syntax(msg)
|
||||
print([[Required:
|
||||
* Neural Interface
|
||||
* Overlay glasses
|
||||
* Entity sensor
|
||||
* Introspection module
|
||||
]]
|
||||
local neural = device['neuralInterface'] or error(Syntax)
|
||||
assert(neural.hasModule('plethora:glasses'), Syntax)
|
||||
assert(neural.hasModule("plethora:sensor"), Syntax)
|
||||
assert(neural.hasModule('plethora:introspection'), Syntax)
|
||||
]])
|
||||
error(msg)
|
||||
end
|
||||
|
||||
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'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user