summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2008-02-07 14:39:15 +0000
committerSimon Marlow <simonmar@microsoft.com>2008-02-07 14:39:15 +0000
commit4dd7f35b7055e3ff9ff5fed9e90e1c8cbe5e6a9b (patch)
treeead4642c9ea4acc5924c54f3a4619e0405019aa0
parent17327d9b57536f5a046909325fa2a0018140f322 (diff)
downloadhaskell-4dd7f35b7055e3ff9ff5fed9e90e1c8cbe5e6a9b.tar.gz
Remove old code to get TMPDIR, use System.Directory.getTemporaryDirectory
-rw-r--r--compiler/main/DynFlags.hs29
-rw-r--r--compiler/main/SysTools.lhs28
2 files changed, 6 insertions, 51 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index dbb791ef63..ed5f359b9c 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 484e9e20a2..576c3fc1f1 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