pull/2916/head
robert00s 7 years ago committed by Qingping Hou
parent cc020b901a
commit c749c42b4b

@ -27,7 +27,7 @@ end
function Ftp:run(address, user, pass, path)
local url = generateUrl(address, user, pass) .. path
return FtpApi:listFolder(url)
return FtpApi:listFolder(url, path)
end
function Ftp:downloadFile(item, address, user, pass, path, close)

@ -15,7 +15,7 @@ function FtpApi:nlst(u)
return r and table.concat(t), e
end
function FtpApi:listFolder(address_path)
function FtpApi:listFolder(address_path,folder_path)
local ftp_list = {}
local ftp_file = {}
local type
@ -23,16 +23,18 @@ function FtpApi:listFolder(address_path)
local file_name
local ls_ftp = self:nlst(address_path)
if ls_ftp == nil then return false end
if folder_path == "/" then
folder_path = ""
end
for item in (ls_ftp..'\n'):gmatch'(.-)\r?\n' do
if item ~= '' then
file_name = item:match("([^/]+)$")
extension = item:match("^.+(%..+)$")
item = "/" .. item
if not extension then
type = "folder"
table.insert(ftp_list, {
text = file_name .. "/",
url = item,
url = string.format("%s/%s",folder_path, file_name),
type = type,
})
--show only file with supported formats
@ -40,7 +42,7 @@ function FtpApi:listFolder(address_path)
type = "file"
table.insert(ftp_file, {
text = file_name,
url = item,
url = string.format("%s/%s",folder_path, file_name),
type = type,
})
end

Loading…
Cancel
Save