-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilelist.lua
More file actions
55 lines (43 loc) · 968 Bytes
/
Copy pathfilelist.lua
File metadata and controls
55 lines (43 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--this is a function that turns a comma-separated list of patterns into a list of files
--with support for doing that over ssh
function get_filelist_ssh(files, pattern)
local S, str, path
S=stream.STREAM(pattern, "l")
if S ~= nil
then
str=S:readln()
while str ~= ni
do
str=strutil.trim(str)
path=filesys.dirname(pattern) .. "/" .. filesys.basename(str)
table.insert(files, path)
str=S:readln()
end
S:close()
end
end
function get_filelist_glob(files, pattern)
local glob, path
glob=filesys.GLOB(pattern)
path=glob:next()
while path ~= nil
do
table.insert(files, path)
path=glob:next()
end
end
function get_filelist(patterns)
local toks, pattern
local files={}
toks=strutil.TOKENIZER(patterns, ",", "Q")
pattern=toks:next()
while pattern ~= nil
do
pattern=strutil.trim(pattern)
if string.sub(pattern, 1, 4) == "ssh:" then get_filelist_ssh(files, pattern)
else get_filelist_glob(files, pattern)
end
pattern=toks:next()
end
return files
end