Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- withHandle :: NFData a => Maybe FileMode -> OpenMode -> RawFilePath -> OpenFileFlags -> (Handle -> IO a) -> IO a
- withHandleAtomic :: NFData a => RawFilePath -> (Handle -> IO (Maybe RawFilePath, a)) -> IO a
- data TempFile = TempFile {
- tempHandle :: Handle
- tempFileName :: RawFilePath
- tempTemplate :: RawFilePath
- closeTempFile :: Maybe RawFilePath -> IO ()
- tempFile :: RawFilePath -> IO TempFile
- readFileFlags :: OpenFileFlags
- readRawFileL :: RawFilePath -> IO ByteString
- readRawFileS :: RawFilePath -> IO ByteString
- writeRawFileL :: RawFilePath -> ByteString -> IO ()
- writeRawFileS :: RawFilePath -> ByteString -> IO ()
- whenFileExists :: MonadIO m => RawFilePath -> a -> m a -> m a
- mwhenFileExists :: (MonadIO m, Alternative f) => RawFilePath -> m a -> m (f a)
- getRawDirectoryContents :: RawFilePath -> IO [RawFilePath]
- createRawDirectoryIfMissing :: Bool -> RawFilePath -> IO ()
- withRawCurrentDirectory :: RawFilePath -> IO a -> IO a
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
, the temp file is Just
tgtrename
d to tgt
, otherwise
we use the template.
An open temp file.
TempFile | |
|
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
.
:: 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.
withRawCurrentDirectory :: RawFilePath -> IO a -> IO a Source #
A version of withCurrentDirectory
using a RawFilePath
.