import Hugs.Directory
#endif /* __HUGS__ */
+#if defined(__GLASGOW_HASKELL__) || defined(mingw32_HOST_OS)
+import Foreign
+import Foreign.C
+#endif
+
#ifdef __GLASGOW_HASKELL__
import Prelude
import System.Posix.Internals
import System.Time ( ClockTime(..) )
import System.IO
-import Foreign
-import Foreign.C
import GHC.IOBase ( IOException(..), IOErrorType(..), ioException )
-- such executable. For example (findExecutable \"ghc\")
-- gives you the path to GHC.
findExecutable :: String -> IO (Maybe FilePath)
-findExecutable binary = do
+findExecutable binary =
#if defined(mingw32_HOST_OS)
withCString binary $ \c_binary ->
withCString ('.':exeExtension) $ \c_ext ->
return (Just fpath)
else return Nothing
-foreign import stdcall unsafe "SearchPath"
+foreign import stdcall unsafe "SearchPathA"
c_SearchPath :: CString
-> CString
-> CString
-> CString
-> Ptr CString
-> IO CInt
+# if !defined(__GLASGOW_HASKELL__)
+long_path_size :: Int
+long_path_size = 4096
+# endif
#else
+ do
path <- getEnv "PATH"
search (parseSearchPath path)
where