hackage-security-0.1.0.0: Hackage security library

Safe HaskellNone
LanguageHaskell2010

Hackage.Security.Util.IO

Contents

Synopsis

Miscelleneous

withTempFile Source

Arguments

:: IsFileSystemRoot root 
=> Path (Rooted root)

Temp directory

-> String

Template

-> (AbsolutePath -> Handle -> IO a)

Callback

-> IO a 

Create a short-lived temporary file

Creates the directory where the temp file should live if it does not exist.

Atomic file operations

atomicCopyFile Source

Arguments

:: AbsolutePath

Source

-> AbsolutePath

Destination

-> IO () 

Copy a file atomically

If both files live in the same directory, we call renameFile. Otherwise we read the source file and call atomicWriteFile (because only when the two files live in the same directory can be sure that the two locations are on the same physical device).

atomicWriteFile Source

Arguments

:: AbsolutePath

Source

-> ByteString

Destination

-> IO () 

Atomically write a bytestring

We write to a temporary file in the destination folder and then rename.

atomicWithFile Source

Arguments

:: AbsolutePath

Final destination

-> (Handle -> IO a)

Callback

-> IO a 

Like 'withFile .. WriteMode', but overwrite the destination atomically.

We open a handle to a temporary file in the same directory as the final location, then call the callback, and only when there are no exceptions finally rename the temporary file to the final destination.