aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Melnichenko <mpeterval@gmail.com>2016-05-07 14:25:56 +0300
committerPeter Melnichenko <mpeterval@gmail.com>2016-05-22 19:50:40 +0300
commit69a6aff477fd794b3b594bc7b9f20775b8e07986 (patch)
treeaa138e4563015fa7e7489e3d19bdb7b4fcc670ac /src
parent8630313d665904e21edcc954e4ca0d043b217665 (diff)
downloadluarocks-69a6aff477fd794b3b594bc7b9f20775b8e07986.tar.gz
luarocks-69a6aff477fd794b3b594bc7b9f20775b8e07986.tar.bz2
luarocks-69a6aff477fd794b3b594bc7b9f20775b8e07986.zip
Move common implementation of tools.dir_iterator
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/fs/tools.lua14
-rw-r--r--src/luarocks/fs/unix/tools.lua14
-rw-r--r--src/luarocks/fs/win32/tools.lua14
3 files changed, 14 insertions, 28 deletions
diff --git a/src/luarocks/fs/tools.lua b/src/luarocks/fs/tools.lua
index 6caa07f3..ed51b545 100644
--- a/src/luarocks/fs/tools.lua
+++ b/src/luarocks/fs/tools.lua
@@ -72,6 +72,20 @@ function tools.execute_string(cmd)
72 end 72 end
73end 73end
74 74
75--- Internal implementation function for fs.dir.
76-- Yields a filename on each iteration.
77-- @param at string: directory to list
78-- @return nil
79function tools.dir_iterator(at)
80 local pipe = io.popen(fs.command_at(at, fs.Q(vars.LS)))
81 for file in pipe:lines() do
82 if file ~= "." and file ~= ".." then
83 coroutine.yield(file)
84 end
85 end
86 pipe:close()
87end
88
75--- Download a remote file. 89--- Download a remote file.
76-- @param url string: URL to be fetched. 90-- @param url string: URL to be fetched.
77-- @param filename string or nil: this function attempts to detect the 91-- @param filename string or nil: this function attempts to detect the
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua
index 1bc307a4..84bd53fd 100644
--- a/src/luarocks/fs/unix/tools.lua
+++ b/src/luarocks/fs/unix/tools.lua
@@ -97,20 +97,6 @@ function tools.delete(arg)
97 fs.execute_quiet(vars.RM, "-rf", arg) 97 fs.execute_quiet(vars.RM, "-rf", arg)
98end 98end
99 99
100--- Internal implementation function for fs.dir.
101-- Yields a filename on each iteration.
102-- @param at string: directory to list
103-- @return nil
104function tools.dir_iterator(at)
105 local pipe = io.popen(fs.command_at(at, vars.LS))
106 for file in pipe:lines() do
107 if file ~= "." and file ~= ".." then
108 coroutine.yield(file)
109 end
110 end
111 pipe:close()
112end
113
114--- Recursively scan the contents of a directory. 100--- Recursively scan the contents of a directory.
115-- @param at string or nil: directory to scan (will be the current 101-- @param at string or nil: directory to scan (will be the current
116-- directory if none is given). 102-- directory if none is given).
diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua
index f54ec9a5..9cb6d47a 100644
--- a/src/luarocks/fs/win32/tools.lua
+++ b/src/luarocks/fs/win32/tools.lua
@@ -97,20 +97,6 @@ function tools.delete(arg)
97 fs.execute_quiet("if exist "..fs.Q(arg.."\\").." ( RMDIR /S /Q "..fs.Q(arg).." ) else ( DEL /Q /F "..fs.Q(arg).." )") 97 fs.execute_quiet("if exist "..fs.Q(arg.."\\").." ( RMDIR /S /Q "..fs.Q(arg).." ) else ( DEL /Q /F "..fs.Q(arg).." )")
98end 98end
99 99
100--- Internal implementation function for fs.dir.
101-- Yields a filename on each iteration.
102-- @param at string: directory to list
103-- @return nil
104function tools.dir_iterator(at)
105 local pipe = io.popen(fs.command_at(at, fs.Q(vars.LS)))
106 for file in pipe:lines() do
107 if file ~= "." and file ~= ".." then
108 coroutine.yield(file)
109 end
110 end
111 pipe:close()
112end
113
114--- Recursively scan the contents of a directory. 100--- Recursively scan the contents of a directory.
115-- @param at string or nil: directory to scan (will be the current 101-- @param at string or nil: directory to scan (will be the current
116-- directory if none is given). 102-- directory if none is given).