Remove old code to get TMPDIR, use System.Directory.getTemporaryDirectory
authorSimon Marlow <simonmar@microsoft.com>
Thu, 7 Feb 2008 14:39:15 +0000 (14:39 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Thu, 7 Feb 2008 14:39:15 +0000 (14:39 +0000)
compiler/main/DynFlags.hs
compiler/main/SysTools.lhs

index dbb791e..ed5f359 100644 (file)
@@ -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
index 484e9e2..576c3fc 100644 (file)
@@ -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