FileCleanup

ghc-8.4.4: The GHC API

Safe Haskell | None
Language | Haskell2010

FileCleanup

Synopsis

- data TempFileLifetime
  - = TFL_CurrentModule
  - | TFL_GhcSession
- cleanTempDirs :: DynFlags -> IO ()
- cleanTempFiles :: DynFlags -> IO ()
- cleanCurrentModuleTempFiles :: DynFlags -> IO ()
- addFilesToClean :: DynFlags -> TempFileLifetime -> [FilePath] -> IO ()
- changeTempFilesLifetime :: DynFlags -> TempFileLifetime -> [FilePath] -> IO ()
- newTempName :: DynFlags -> TempFileLifetime -> Suffix -> IO FilePath
- newTempLibName :: DynFlags -> TempFileLifetime -> Suffix -> IO (FilePath, FilePath, String)
- withSystemTempDirectory :: String -> (FilePath -> IO a) -> IO a
- withTempDirectory :: FilePath -> String -> (FilePath -> IO a) -> IO a

# Documentation

data TempFileLifetime #

Used when a temp file is created. This determines which component Set of FilesToClean will get the temp file

Constructors

TFL_CurrentModule | A file with lifetime TFL_CurrentModule will be cleaned up at the end of upweep_mod
TFL_GhcSession | A file with lifetime TFL_GhcSession will be cleaned up at the end of runGhc(T)

Instances

Show TempFileLifetime # |
Instance details Defined in FileCleanup Methods showsPrec :: Int -> TempFileLifetime -> ShowS Source # show :: TempFileLifetime -> String Source # showList :: [TempFileLifetime] -> ShowS Source #

cleanTempDirs :: DynFlags -> IO () #

cleanTempFiles :: DynFlags -> IO () #

Delete all files in `filesToClean dflags`.

cleanCurrentModuleTempFiles :: DynFlags -> IO () #

Delete all files in `filesToClean dflags`. That have lifetime TFL_CurrentModule. If a file must be cleaned eventually, but must survive a cleanCurrentModuleTempFiles, ensure it has lifetime TFL_GhcSession.

addFilesToClean :: DynFlags -> TempFileLifetime -> [FilePath] -> IO () #

Ensure that new_files are cleaned on the next call of `cleanTempFiles` or `cleanCurrentModuleTempFiles`, depending on lifetime. If any of new_files are already tracked, they will have their lifetime updated.

changeTempFilesLifetime :: DynFlags -> TempFileLifetime -> [FilePath] -> IO () #

Update the lifetime of files already being tracked. If any files are not being tracked they will be discarded.

newTempName :: DynFlags -> TempFileLifetime -> Suffix -> IO FilePath #

newTempLibName :: DynFlags -> TempFileLifetime -> Suffix -> IO (FilePath, FilePath, String) #

withSystemTempDirectory #

Arguments

:: String | Directory name template. See `openTempFile`.
-> (FilePath -> IO a) | Callback that can use the directory
-> IO a |

Create and use a temporary directory in the system standard temporary directory.

Behaves exactly the same as `withTempDirectory`, except that the parent temporary directory will be that returned by `getTemporaryDirectory`.

withTempDirectory #

Arguments

:: FilePath | Temp directory to create the directory in
-> String | Directory name template. See `openTempFile`.
-> (FilePath -> IO a) | Callback that can use the directory
-> IO a |

Create and use a temporary directory.

Creates a new temporary directory inside the given directory, making use of the template. The temp directory is deleted after use. For example:

    withTempDirectory "src" "sdist." $ \tmpDir -> do ...

The `tmpDir` will be a new subdirectory of the given directory, e.g. `src/sdist.342`.