Repository : ssh://darcs.haskell.org//srv/darcs/packages/directory

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/9b42efbdf4202bb50c6834f79f999fb2eee75f2e

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

commit 9b42efbdf4202bb50c6834f79f999fb2eee75f2e
Author: Simon Marlow <[email protected]>
Date:   Mon Jun 4 10:36:53 2012 +0100

    add findFile :: [FilePath] -> String -> IO (Maybe FilePath) (see #6094)
    
    Just an export of part of the implementation of findExecutable, which
    is useful for people wanting to do their own findExecutable using
    something other than the current PATH.

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

 System/Directory.hs |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/System/Directory.hs b/System/Directory.hs
index 1819508..79886ea 100644
--- a/System/Directory.hs
+++ b/System/Directory.hs
@@ -49,6 +49,7 @@ module System.Directory
     , canonicalizePath
     , makeRelativeToCurrentDirectory
     , findExecutable
+    , findFile
 
     -- * Existence tests
     , doesFileExist             -- :: FilePath -> IO Bool
@@ -778,10 +779,14 @@ findExecutable binary =
 #else
  do
   path <- getEnv "PATH"
-  search (splitSearchPath path)
-  where
-    fileName = binary <.> exeExtension
+  findFile (splitSearchPath path) (binary <.> exeExtension)
+#endif
 
+-- | Search through the given set of directories for the given file.
+-- Used by 'findExecutable' on non-windows platforms.
+findFile :: [FilePath] -> String -> IO (Maybe FilePath)
+findFile paths fileName = search paths
+  where
     search :: [FilePath] -> IO (Maybe FilePath)
     search [] = return Nothing
     search (d:ds) = do
@@ -789,8 +794,6 @@ findExecutable binary =
         b <- doesFileExist path
         if b then return (Just path)
              else search ds
-#endif
-
 
 #ifdef __GLASGOW_HASKELL__
 {- |@'getDirectoryContents' dir@ returns a list of /all/ entries



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to