miss-0: A Haskell git implimentation

Safe HaskellSafe
LanguageHaskell2010

Data.Git.Internal.FileUtil

Description

 
Synopsis

Documentation

withHandle :: NFData a => Maybe FileMode -> OpenMode -> RawFilePath -> OpenFileFlags -> (Handle -> IO a) -> IO a Source #

A somewhat more involved version of withFile.

withHandleAtomic :: NFData a => RawFilePath -> (Handle -> IO (Maybe RawFilePath, a)) -> IO a Source #

Uses mkstemp (with the given path as the filename template) instead of the withHandle machinery to open the temp file. The awkward type in the callback is to let the user compute the name of the output file---when Just tgt, the temp file is renamed to tgt, otherwise we use the template.

data TempFile Source #

An open temp file.

Constructors

TempFile 

Fields

tempFile :: RawFilePath -> IO TempFile Source #

Make a TempFile using the given RawFilePath as a template for mkstemp.

readFileFlags :: OpenFileFlags Source #

Flags to open a file for reading

readRawFileL :: RawFilePath -> IO ByteString Source #

Read a file into a lazy ByteString.

readRawFileS :: RawFilePath -> IO ByteString Source #

Read a file into a strict ByteString.

writeRawFileL :: RawFilePath -> ByteString -> IO () Source #

Write a lazy ByteString to a file via withHandleAtomic.

writeRawFileS :: RawFilePath -> ByteString -> IO () Source #

Write a strict ByteString to a file via withHandleAtomic.

whenFileExists Source #

Arguments

:: MonadIO m 
=> RawFilePath 
-> a

Return this when the file doesn't exist.

-> m a

Do this when it does.

-> m a 

Do something when a file exists.

mwhenFileExists :: (MonadIO m, Alternative f) => RawFilePath -> m a -> m (f a) Source #

Like whenFileExists, with empty as a default.

getRawDirectoryContents :: RawFilePath -> IO [RawFilePath] Source #

Lists the files in a directory.

createRawDirectoryIfMissing :: Bool -> RawFilePath -> IO () Source #

This is stolen directly from createDirectoryIfMissing, swapped to use functions from FilePath. NB: due to the absence of a normalise function in the latter module, this function doesn't do any normalization.