Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
d7fdebe8
Commit
d7fdebe8
authored
Jul 10, 2006
by
Ian Lynagh
Browse files
Pull out common removal code, and detect does-not-exist correctly
parent
8a994e17
Changes
1
Hide whitespace changes
Inline
Side-by-side
compiler/main/SysTools.lhs
View file @
d7fdebe8
...
...
@@ -615,19 +615,14 @@ removeTmpDirs :: DynFlags -> [FilePath] -> IO ()
removeTmpDirs dflags ds
= traceCmd dflags "Deleting temp dirs"
("Deleting: " ++ unwords ds)
(mapM_ rmdir ds)
where
rmdir d = removeDirectory d `IO.catch`
(\_ignored ->
debugTraceMsg dflags 2 (ptext SLIT("Warning: deleting") <+> text d <+> ptext SLIT("raised exception"))
)
(mapM_ (removeWith dflags removeDirectory) ds)
removeTmpFiles :: DynFlags -> [FilePath] -> IO ()
removeTmpFiles dflags fs
= warnNon $
traceCmd dflags "Deleting temp files"
("Deleting: " ++ unwords deletees)
(mapM_
rm
deletees)
(mapM_
(removeWith dflags removeFile)
deletees)
where
-- Flat out refuse to delete files that are likely to be source input
-- files (is there a worse bug than having a compiler delete your source
...
...
@@ -643,11 +638,16 @@ removeTmpFiles dflags fs
(non_deletees, deletees) = partition isHaskellUserSrcFilename fs
rm f = removeFile f `IO.catch`
(\_ignored ->
debugTraceMsg dflags 2 (ptext SLIT("Warning: deleting non-existent") <+> text f)
)
removeWith :: DynFlags -> (FilePath -> IO ()) -> FilePath -> IO ()
removeWith dflags remover f = remover f `IO.catch`
(\e ->
let msg = if isDoesNotExistError e
then ptext SLIT("Warning: deleting non-existent") <+> text f
else ptext SLIT("Warning: exception raised when deleting")
<+> text f <> colon
$$ text (show e)
in debugTraceMsg dflags 2 msg
)
-----------------------------------------------------------------------------
-- Running an external program
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment