[project @ 2001-07-11 10:17:51 by rrt]
authorrrt <unknown>
Wed, 11 Jul 2001 10:17:51 +0000 (10:17 +0000)
committerrrt <unknown>
Wed, 11 Jul 2001 10:17:51 +0000 (10:17 +0000)
Rewrite getExecDir to use GetModuleFileName on Windows (thanks, sof),
and switch unDosifyPath's definitions between Windows and Unix so that
it actually does something on Windows.

ghc/compiler/main/SysTools.lhs

index 587137a..399f9db 100644 (file)
@@ -61,7 +61,7 @@ import System         ( system, ExitCode(..), exitWith )
 #if !defined(mingw32_TARGET_OS)
 import qualified Posix
 #else
-import Win32Registry
+import Win32DLL
 import List            ( isPrefixOf )
 #endif
 
@@ -622,10 +622,10 @@ pgmPath :: String         -- Directory string in Unix format
 #if defined(mingw32_TARGET_OS)
 
 --------------------- Windows version ------------------
-unDosifyPath xs = xs
-
 dosifyPaths xs = map dosifyPath xs
 
+unDosifyPath xs = subst '\\' '/' xs
+
 pgmPath dir pgm = dosifyPath dir ++ '\\' : pgm
 
 dosifyPath stuff
@@ -643,7 +643,7 @@ dosifyPath stuff
 
 --------------------- Unix version ---------------------
 dosifyPaths  ps = ps
-unDosifyPath xs = subst '\\' '/' xs
+unDosifyPath xs = xs
 pgmPath dir pgm = dir ++ '/' : pgm
 --------------------------------------------------------
 #endif
@@ -683,9 +683,9 @@ slash s1 s2 = s1 ++ ('/' : s2)
 
 #if defined(mingw32_TARGET_OS)
 getExecDir :: IO (Maybe String)
-getExecDir = do hKey <- regOpenKey hKEY_LOCAL_MACHINE "SOFTWARE\\University of Glasgow\\Glasgow Haskell Compiler\\ghc-5.01"
-                s <- regQueryValue hKey (Just "InstallDir")
-               if s == "" then return Nothing else return (Just s)
+getExecDir = do h <- getModuleHandle Nothing
+               n <- getModuleFileName h
+               return (Just (reverse (tail (dropWhile (not .isSlash) (reverse (unDosifyPath n))))))
 #else
 getExecDir :: IO (Maybe String) = do return Nothing
 #endif