From 1fffceb5499b952f2faabc9c2ed957fad6d3787b Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 10 Sep 2017 03:06:40 +1000 Subject: [PATCH] moved wget to exec/ and turned it into a standalone program. --- build.cfg | 2 +- exec/wget.lua | 16 ++++++++++++++++ modules/lib/wget.lua | 13 ------------- 3 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 exec/wget.lua delete mode 100644 modules/lib/wget.lua diff --git a/build.cfg b/build.cfg index 2ff4a83..d2a469a 100755 --- a/build.cfg +++ b/build.cfg @@ -17,7 +17,6 @@ modules/lib/readline.lua modules/lib/shutil.lua modules/lib/sha256.lua modules/lib/userlib.lua -modules/lib/wget.lua modules/net/net-ext.lua modules/applications/login.lua modules/applications/luash.lua @@ -25,6 +24,7 @@ modules/applications/genkernel.lua fwrap skex exec/skex2.lua fwrap nshd exec/nshd.lua fwrap nsh exec/nsh.lua +fwrap wget exec/wget.lua modules/util/fs-automount.lua modules/setup.lua modules/base/footer.lua diff --git a/exec/wget.lua b/exec/wget.lua new file mode 100644 index 0000000..b8b6ee1 --- /dev/null +++ b/exec/wget.lua @@ -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() diff --git a/modules/lib/wget.lua b/modules/lib/wget.lua deleted file mode 100644 index 9cc0109..0000000 --- a/modules/lib/wget.lua +++ /dev/null @@ -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