format and installer branches
This commit is contained in:
@@ -5,91 +5,91 @@ local fs = _G.fs
|
||||
local urlfs = { }
|
||||
|
||||
function urlfs.mount(_, url)
|
||||
if not url then
|
||||
error('URL is required')
|
||||
end
|
||||
return {
|
||||
url = url,
|
||||
}
|
||||
if not url then
|
||||
error('URL is required')
|
||||
end
|
||||
return {
|
||||
url = url,
|
||||
}
|
||||
end
|
||||
|
||||
function urlfs.delete(_, dir)
|
||||
fs.unmount(dir)
|
||||
fs.unmount(dir)
|
||||
end
|
||||
|
||||
function urlfs.exists()
|
||||
return true
|
||||
return true
|
||||
end
|
||||
|
||||
function urlfs.getSize(node)
|
||||
return node.size or 0
|
||||
return node.size or 0
|
||||
end
|
||||
|
||||
function urlfs.isReadOnly()
|
||||
return true
|
||||
return true
|
||||
end
|
||||
|
||||
function urlfs.isDir()
|
||||
return false
|
||||
return false
|
||||
end
|
||||
|
||||
function urlfs.getDrive()
|
||||
return 'url'
|
||||
return 'url'
|
||||
end
|
||||
|
||||
function urlfs.open(node, fn, fl)
|
||||
|
||||
if fl == 'w' or fl == 'wb' then
|
||||
fs.delete(fn)
|
||||
return fs.open(fn, fl)
|
||||
end
|
||||
if fl == 'w' or fl == 'wb' then
|
||||
fs.delete(fn)
|
||||
return fs.open(fn, fl)
|
||||
end
|
||||
|
||||
if fl ~= 'r' and fl ~= 'rb' then
|
||||
error('Unsupported mode')
|
||||
end
|
||||
if fl ~= 'r' and fl ~= 'rb' then
|
||||
error('Unsupported mode')
|
||||
end
|
||||
|
||||
local c = node.cache
|
||||
if not c then
|
||||
c = Util.httpGet(node.url)
|
||||
if c then
|
||||
node.cache = c
|
||||
node.size = #c
|
||||
end
|
||||
end
|
||||
local c = node.cache
|
||||
if not c then
|
||||
c = Util.httpGet(node.url)
|
||||
if c then
|
||||
node.cache = c
|
||||
node.size = #c
|
||||
end
|
||||
end
|
||||
|
||||
if not c then
|
||||
return
|
||||
end
|
||||
if not c then
|
||||
return
|
||||
end
|
||||
|
||||
local ctr = 0
|
||||
local lines
|
||||
local ctr = 0
|
||||
local lines
|
||||
|
||||
if fl == 'r' then
|
||||
return {
|
||||
readLine = function()
|
||||
if not lines then
|
||||
lines = Util.split(c)
|
||||
end
|
||||
ctr = ctr + 1
|
||||
return lines[ctr]
|
||||
end,
|
||||
readAll = function()
|
||||
return c
|
||||
end,
|
||||
close = function()
|
||||
lines = nil
|
||||
end,
|
||||
}
|
||||
end
|
||||
return {
|
||||
read = function()
|
||||
ctr = ctr + 1
|
||||
return c:sub(ctr, ctr):byte()
|
||||
end,
|
||||
close = function()
|
||||
ctr = 0
|
||||
end,
|
||||
}
|
||||
if fl == 'r' then
|
||||
return {
|
||||
readLine = function()
|
||||
if not lines then
|
||||
lines = Util.split(c)
|
||||
end
|
||||
ctr = ctr + 1
|
||||
return lines[ctr]
|
||||
end,
|
||||
readAll = function()
|
||||
return c
|
||||
end,
|
||||
close = function()
|
||||
lines = nil
|
||||
end,
|
||||
}
|
||||
end
|
||||
return {
|
||||
read = function()
|
||||
ctr = ctr + 1
|
||||
return c:sub(ctr, ctr):byte()
|
||||
end,
|
||||
close = function()
|
||||
ctr = 0
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
return urlfs
|
||||
|
||||
Reference in New Issue
Block a user