Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Temporary file-system management
Synopsis
- data TmpFs
- initTmpFs :: IO TmpFs
- forkTmpFsFrom :: TmpFs -> IO TmpFs
- mergeTmpFsInto :: TmpFs -> TmpFs -> IO ()
- data FilesToClean = FilesToClean {
- ftcGhcSession :: !(Set FilePath)
- ftcCurrentModule :: !(Set FilePath)
- emptyFilesToClean :: FilesToClean
- data TempFileLifetime
- newtype TempDir = TempDir FilePath
- cleanTempDirs :: Logger -> TmpFs -> IO ()
- cleanTempFiles :: Logger -> TmpFs -> IO ()
- cleanCurrentModuleTempFiles :: Logger -> TmpFs -> IO ()
- addFilesToClean :: TmpFs -> TempFileLifetime -> [FilePath] -> IO ()
- changeTempFilesLifetime :: TmpFs -> TempFileLifetime -> [FilePath] -> IO ()
- newTempName :: Logger -> TmpFs -> TempDir -> TempFileLifetime -> Suffix -> IO FilePath
- newTempLibName :: Logger -> TmpFs -> TempDir -> TempFileLifetime -> Suffix -> IO (FilePath, FilePath, String)
- newTempDir :: Logger -> TmpFs -> TempDir -> IO FilePath
- withSystemTempDirectory :: String -> (FilePath -> IO a) -> IO a
- withTempDirectory :: FilePath -> String -> (FilePath -> IO a) -> IO a
Documentation
forkTmpFsFrom :: TmpFs -> IO TmpFs Source #
Initialise an empty TmpFs sharing unique numbers and per-process temporary directories with the given TmpFs
mergeTmpFsInto :: TmpFs -> TmpFs -> IO () Source #
Merge the first TmpFs into the second.
The first TmpFs is returned emptied.
data FilesToClean Source #
A collection of files that must be deleted before ghc exits.
FilesToClean | |
|
emptyFilesToClean :: FilesToClean Source #
An empty FilesToClean
data TempFileLifetime Source #
Used when a temp file is created. This determines which component Set of FilesToClean will get the temp file
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 Source # | |
Defined in GHC.Utils.TmpFs showsPrec :: Int -> TempFileLifetime -> ShowS # show :: TempFileLifetime -> String # showList :: [TempFileLifetime] -> ShowS # |
cleanCurrentModuleTempFiles :: Logger -> TmpFs -> IO () Source #
Delete all files in tmp_files_to_clean
. That have lifetime
TFL_CurrentModule.
If a file must be cleaned eventually, but must survive a
cleanCurrentModuleTempFiles, ensure it has lifetime TFL_GhcSession.
addFilesToClean :: TmpFs -> TempFileLifetime -> [FilePath] -> IO () Source #
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 :: TmpFs -> TempFileLifetime -> [FilePath] -> IO () Source #
Update the lifetime of files already being tracked. If any files are not being tracked they will be discarded.
newTempName :: Logger -> TmpFs -> TempDir -> TempFileLifetime -> Suffix -> IO FilePath Source #
newTempLibName :: Logger -> TmpFs -> TempDir -> TempFileLifetime -> Suffix -> IO (FilePath, FilePath, String) Source #
withSystemTempDirectory Source #
:: String | Directory name template. See |
-> (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
.
:: FilePath | Temp directory to create the directory in |
-> String | Directory name template. See |
-> (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
.