From: Simon Marlow Date: Thu, 7 Feb 2008 14:39:15 +0000 (+0000) Subject: Remove old code to get TMPDIR, use System.Directory.getTemporaryDirectory X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=4dd7f35b7055e3ff9ff5fed9e90e1c8cbe5e6a9b;p=ghc-hetmet.git Remove old code to get TMPDIR, use System.Directory.getTemporaryDirectory --- diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index dbb791e..ed5f359 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -1652,32 +1652,9 @@ splitPathList s = filter notNull (splitUp s) -- tmpDir, where we store temporary files. setTmpDir :: FilePath -> DynFlags -> DynFlags -setTmpDir dir dflags = dflags{ tmpDir = canonicalise dir } - where -#if !defined(mingw32_HOST_OS) - canonicalise p = normalise p -#else - -- Canonicalisation of temp path under win32 is a bit more - -- involved: (a) strip trailing slash, - -- (b) normalise slashes - -- (c) just in case, if there is a prefix /cygdrive/x/, change to x: - canonicalise path = removeTrailingSlash $ normalise $ xltCygdrive path - - -- if we're operating under cygwin, and TMP/TEMP is of - -- the form "/cygdrive/drive/path", translate this to - -- "drive:/path" (as GHC isn't a cygwin app and doesn't - -- understand /cygdrive paths.) - cygdrivePrefix = [pathSeparator] ++ "/cygdrive/" ++ [pathSeparator] - xltCygdrive path = case maybePrefixMatch cygdrivePrefix path of - Just (drive:sep:xs) - | isPathSeparator sep -> drive:':':pathSeparator:xs - _ -> path - - -- strip the trailing backslash (awful, but we only do this once). - removeTrailingSlash path - | isPathSeparator (last path) = init path - | otherwise = path -#endif +setTmpDir dir dflags = dflags{ tmpDir = normalise dir } + -- we used to fix /cygdrive/c/.. on Windows, but this doesn't + -- seem necessary now --SDM 7/2/2008 ----------------------------------------------------------------------------- -- Hpc stuff diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs index 484e9e2..576c3fc 100644 --- a/compiler/main/SysTools.lhs +++ b/compiler/main/SysTools.lhs @@ -207,31 +207,9 @@ initSysTools mbMinusB dflags | otherwise = "windres" ; let dflags0 = defaultDynFlags -#ifndef mingw32_HOST_OS - -- check whether TMPDIR is set in the environment - ; e_tmpdir <- IO.try (getEnv "TMPDIR") -- fails if not set -#else - -- On Win32, consult GetTempPath() for a temp dir. - -- => it first tries TMP, TEMP, then finally the - -- Windows directory(!). The directory is in short-path - -- form. - ; e_tmpdir <- - IO.try (do - let len = (2048::Int) - buf <- mallocArray len - ret <- getTempPath len buf - if ret == 0 then do - -- failed, consult TMPDIR. - free buf - getEnv "TMPDIR" - else do - s <- peekCString buf - free buf - return s) -#endif - ; let dflags1 = case e_tmpdir of - Left _ -> dflags0 - Right d -> setTmpDir d dflags0 + + ; tmpdir <- getTemporaryDirectory + ; let dflags1 = setTmpDir tmpdir dflags0 -- Check that the package config exists ; config_exists <- doesFileExist pkgconfig_path