From cdce73b226cc4da6a073b79bec02a6780d32ff1a Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Fri, 4 Mar 2016 14:38:56 -0300 Subject: Added support for FTP command lists --- src/ftp.lua | 15 ++++++++++++--- src/ltn12.lua | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ftp.lua b/src/ftp.lua index 917cd89..e0c3cae 100644 --- a/src/ftp.lua +++ b/src/ftp.lua @@ -271,8 +271,17 @@ _M.command = socket.protect(function(cmdt) local f = _M.open(cmdt.host, cmdt.port, cmdt.create) f:greet() f:login(cmdt.user, cmdt.password) - f.try(f.tp:command(cmdt.command, cmdt.argument)) - if cmdt.check then f.try(f.tp:check(cmdt.check)) end + if type(cmdt.command) == "table" then + local argument = cmdt.argument or {} + local check = cmdt.check or {} + for i,cmd in ipairs(cmdt.command) do + f.try(f.tp:command(cmd, argument[i])) + if check[i] then f.try(f.tp:check(check[i])) end + end + else + f.try(f.tp:command(cmdt.command, cmdt.argument)) + if cmdt.check then f.try(f.tp:check(cmdt.check)) end + end f:quit() return f:close() end) @@ -282,4 +291,4 @@ _M.get = socket.protect(function(gett) else return tget(gett) end end) -return _M \ No newline at end of file +return _M diff --git a/src/ltn12.lua b/src/ltn12.lua index dede0fa..575c5a7 100644 --- a/src/ltn12.lua +++ b/src/ltn12.lua @@ -22,6 +22,9 @@ _M.source = source _M.sink = sink _M.pump = pump +local unpack = unpack or table.unpack +local select = base.select + -- 2048 seems to be better in windows... _M.BLOCKSIZE = 2048 _M._VERSION = "LTN12 1.0.3" -- cgit v1.2.3-55-g6feb