safeio-0.0.4.0: Write output to disk atomically

Safe HaskellSafe
LanguageHaskell2010

System.IO.SafeWrite

Synopsis

Documentation

withOutputFile Source #

Arguments

:: FilePath

Final desired file path

-> (Handle -> IO a)

action to execute

-> IO a 

Variation of withFile for output files.

Output is written to a temporary file. Once the action has completed, this file is then sync'ed to disk (see |syncFile|) and renamed to its final destination. In Posix, this is an atomic operation. If an exception is raised, then the temporary output file will be deleted and not saved to disk. Thus, the result file will either contain the complete result or will be empty.

syncFile Source #

Arguments

:: FilePath

File to sync

-> IO () 

Sync a file to disk

Only supported on Posix (patches with Windows support are welcome)