[commit: packages/directory] master: Add findExecutablesInDirectories (e4a6a38)

git at git.haskell.org git at git.haskell.org
Fri Dec 18 09:52:24 UTC 2015


Repository : ssh://git@git.haskell.org/directory

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/e4a6a3824d837a9bcd95b91a841ce04d74e05b7e/directory

>---------------------------------------------------------------

commit e4a6a3824d837a9bcd95b91a841ce04d74e05b7e
Author: Daniel Gröber <dxld at darkboxed.org>
Date:   Fri Aug 28 04:35:58 2015 +0200

    Add findExecutablesInDirectories


>---------------------------------------------------------------

e4a6a3824d837a9bcd95b91a841ce04d74e05b7e
 System/Directory.hs | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/System/Directory.hs b/System/Directory.hs
index b3c7fb8..adfa2fe 100644
--- a/System/Directory.hs
+++ b/System/Directory.hs
@@ -53,6 +53,7 @@ module System.Directory
     , makeRelativeToCurrentDirectory
     , findExecutable
     , findExecutables
+    , findExecutablesInDirectories
     , findFile
     , findFiles
     , findFilesWith
@@ -913,11 +914,17 @@ findExecutables binary = do
     return $ maybeToList file
 #else
     path <- getEnv "PATH"
-    findFilesWith isExecutable (splitSearchPath path) (binary <.> exeExtension)
+    findExecutablesInDirectories (splitSearchPath path) binary
+#endif
+
+-- | Given a file name, searches for the file on the given paths and returns a
+-- list of all occurences that are executable.
+findExecutablesInDirectories :: [FilePath] -> String -> IO [FilePath]
+findExecutablesInDirectories path binary =
+    findFilesWith isExecutable path (binary <.> exeExtension)
   where isExecutable file = do
             perms <- getPermissions file
             return $ executable perms
-#endif
 
 -- | Search through the given set of directories for the given file.
 -- Used by 'findExecutable' on non-windows platforms.



More information about the ghc-commits mailing list