[project @ 2004-11-14 20:25:54 by panne]
[haskell-directory.git] / System / Directory.hs
index 20e041f..d3133d4 100644 (file)
@@ -62,12 +62,13 @@ module System.Directory
     , getModificationTime       -- :: FilePath -> IO ClockTime
    ) where
 
+import System.Environment      ( getEnv )
+import System.FilePath
+import System.IO.Error
+
 #ifdef __NHC__
 import Directory
-import System (getEnv)
-import System.FilePath
 import NHC.FFI
-import IO (try)
 #endif /* __NHC__ */
 
 #ifdef __HUGS__
@@ -83,9 +84,6 @@ import System.Posix.Types
 import System.Posix.Internals
 import System.Time             ( ClockTime(..) )
 import System.IO
-import System.IO.Error
-import System.FilePath
-import System.Environment (getEnv)
 import Foreign
 import Foreign.C
 
@@ -525,11 +523,7 @@ findExecutable binary = do
   path <- getEnv "PATH"
   search (parseSearchPath path)
   where
-#ifdef mingw32_TARGET_OS
-    fileName = binary `joinFileExt` "exe"
-#else
-    fileName = binary
-#endif
+    fileName = binary `joinFileExt` drop 1 exeExt
 
     search :: [FilePath] -> IO (Maybe FilePath)
     search [] = return Nothing
@@ -539,6 +533,14 @@ findExecutable binary = do
        if b then return (Just path)
              else search ds
 
+-- ToDo: This should be determined via autoconf (AC_EXEEXT)
+exeExt :: String
+#ifdef mingw32_TARGET_OS
+exeExt = ".exe"
+#else
+exeExt = ""
+#endif
+
 #ifdef __GLASGOW_HASKELL__
 {- |@'getDirectoryContents' dir@ returns a list of /all/ entries
 in /dir/.