moved wget to exec/ and turned it into a standalone program.

This commit is contained in:
Izaya 2017-09-10 03:06:40 +10:00
parent 064064eb26
commit 1fffceb549
3 changed files with 17 additions and 14 deletions

View File

@ -17,7 +17,6 @@ modules/lib/readline.lua
modules/lib/shutil.lua modules/lib/shutil.lua
modules/lib/sha256.lua modules/lib/sha256.lua
modules/lib/userlib.lua modules/lib/userlib.lua
modules/lib/wget.lua
modules/net/net-ext.lua modules/net/net-ext.lua
modules/applications/login.lua modules/applications/login.lua
modules/applications/luash.lua modules/applications/luash.lua
@ -25,6 +24,7 @@ modules/applications/genkernel.lua
fwrap skex exec/skex2.lua fwrap skex exec/skex2.lua
fwrap nshd exec/nshd.lua fwrap nshd exec/nshd.lua
fwrap nsh exec/nsh.lua fwrap nsh exec/nsh.lua
fwrap wget exec/wget.lua
modules/util/fs-automount.lua modules/util/fs-automount.lua
modules/setup.lua modules/setup.lua
modules/base/footer.lua modules/base/footer.lua

16
exec/wget.lua Normal file
View File

@ -0,0 +1,16 @@
local tA = {...}
local url = tA[1]
local path = tA[2]
local R=component.internet.request(url)
if not R then return false end
local f=io.open(path,"wb")
if not f then return false end
repeat
coroutine.yield()
until R.finishConnect()
repeat
coroutine.yield()
ns = R.read(2048)
f:write(ns or "")
until not ns
f:close()

View File

@ -1,13 +0,0 @@
function wget(url)
local R=component.internet.request(url)
repeat
coroutine.yield()
until R.finishConnect()
S=""
repeat
coroutine.yield()
ns = R.read(2048)
S = S .. (ns or "")
until not ns
return S
end