From 69a6aff477fd794b3b594bc7b9f20775b8e07986 Mon Sep 17 00:00:00 2001
From: Peter Melnichenko <mpeterval@gmail.com>
Date: Sat, 7 May 2016 14:25:56 +0300
Subject: Move common implementation of tools.dir_iterator

---
 src/luarocks/fs/tools.lua       | 14 ++++++++++++++
 src/luarocks/fs/unix/tools.lua  | 14 --------------
 src/luarocks/fs/win32/tools.lua | 14 --------------
 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)
    end
 end
 
+--- Internal implementation function for fs.dir.
+-- Yields a filename on each iteration.
+-- @param at string: directory to list
+-- @return nil
+function tools.dir_iterator(at)
+   local pipe = io.popen(fs.command_at(at, fs.Q(vars.LS)))
+   for file in pipe:lines() do
+      if file ~= "." and file ~= ".." then
+         coroutine.yield(file)
+      end
+   end
+   pipe:close()
+end
+
 --- Download a remote file.
 -- @param url string: URL to be fetched.
 -- @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)
    fs.execute_quiet(vars.RM, "-rf", arg)
 end
 
---- Internal implementation function for fs.dir.
--- Yields a filename on each iteration.
--- @param at string: directory to list
--- @return nil
-function tools.dir_iterator(at)
-   local pipe = io.popen(fs.command_at(at, vars.LS))
-   for file in pipe:lines() do
-      if file ~= "." and file ~= ".." then
-         coroutine.yield(file)
-      end
-   end
-   pipe:close()
-end
-
 --- Recursively scan the contents of a directory.
 -- @param at string or nil: directory to scan (will be the current
 -- 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)
    fs.execute_quiet("if exist "..fs.Q(arg.."\\").." ( RMDIR /S /Q "..fs.Q(arg).." ) else ( DEL /Q /F "..fs.Q(arg).." )")
 end
 
---- Internal implementation function for fs.dir.
--- Yields a filename on each iteration.
--- @param at string: directory to list
--- @return nil
-function tools.dir_iterator(at)
-   local pipe = io.popen(fs.command_at(at, fs.Q(vars.LS)))
-   for file in pipe:lines() do
-      if file ~= "." and file ~= ".." then
-         coroutine.yield(file)
-      end
-   end
-   pipe:close()
-end
-
 --- Recursively scan the contents of a directory.
 -- @param at string or nil: directory to scan (will be the current
 -- directory if none is given).
-- 
cgit v1.2.3-55-g6feb