From e9622e23db18fff2916eb6ebe40d37da237d994a Mon Sep 17 00:00:00 2001 From: rrt Date: Wed, 11 Jul 2001 10:17:51 +0000 Subject: [PATCH] [project @ 2001-07-11 10:17:51 by rrt] 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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ghc/compiler/main/SysTools.lhs b/ghc/compiler/main/SysTools.lhs index 587137a..399f9db 100644 --- a/ghc/compiler/main/SysTools.lhs +++ b/ghc/compiler/main/SysTools.lhs @@ -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 -- 1.7.10.4