[project @ 2000-11-13 12:43:20 by sewardj]
[ghc-hetmet.git] / ghc / compiler / main / TmpFiles.hs
index adf6835..90ebcc2 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: TmpFiles.hs,v 1.2 2000/10/11 11:54:58 simonmar Exp $
+-- $Id: TmpFiles.hs,v 1.8 2000/10/30 09:52:15 simonpj Exp $
 --
 -- Temporary file management
 --
@@ -12,16 +12,15 @@ module TmpFiles (
    initTempFileStorage,  -- :: IO ()
    cleanTempFiles,       -- :: IO ()
    newTempName,                 -- :: Suffix -> IO FilePath
-   addFilesToClean      -- :: [FilePath] -> IO ()
+   addFilesToClean,     -- :: [FilePath] -> IO ()
+   v_TmpDir
  ) where
 
 -- main
-import DriverState
 import Config
 import Util
 
 -- hslibs
-import Posix
 import Exception
 import IOExts
 
@@ -34,6 +33,8 @@ import Monad
 #include "HsVersions.h"
 
 GLOBAL_VAR(v_FilesToClean, [],               [String] )
+GLOBAL_VAR(v_TmpDir,       cDEFAULT_TMPDIR,  String   )
+
 
 initTempFileStorage = do
        -- check whether TMPDIR is set in the environment
@@ -46,12 +47,12 @@ cleanTempFiles verbose = do
   fs <- readIORef v_FilesToClean
 
   let blowAway f =
-          (do  when verbose (hPutStrLn stderr ("removing: " ++ f))
+          (do  when verbose (hPutStrLn stderr ("Removing: " ++ f))
                if '*' `elem` f then system ("rm -f " ++ f) >> return ()
                                else removeFile f)
            `catchAllIO`
           (\_ -> when verbose (hPutStrLn stderr 
-                               ("warning: can't remove tmp file" ++ f)))
+                               ("Warning: can't remove tmp file " ++ f)))
   mapM_ blowAway fs
 
 type Suffix = String
@@ -59,7 +60,7 @@ type Suffix = String
 -- find a temporary name that doesn't already exist.
 newTempName :: Suffix -> IO FilePath
 newTempName extn = do
-  x <- getProcessID
+  x <- myGetProcessID
   tmp_dir <- readIORef v_TmpDir
   findTempName tmp_dir x
   where findTempName tmp_dir x = do