io-streams-1.3.5.0: Simple, composable, and easy-to-use stream I/O

Safe HaskellNone
LanguageHaskell2010

System.IO.Streams.File

Contents

Description

Input and output streams for files.

The functions in this file use "with*" or "bracket" semantics, i.e. they open the supplied FilePath, run a user computation, and then close the file handle. If you need more control over the lifecycle of the underlying file descriptor resources, you are encouraged to use the functions from System.IO.Streams.Handle instead.

Synopsis

File conversions

withFileAsInput Source

Arguments

:: FilePath

file to open

-> (InputStream ByteString -> IO a)

function to run

-> IO a 

withFileAsInput name act opens the specified file in "read mode" and passes the resulting InputStream to the computation act. The file will be closed on exit from withFileAsInput, whether by normal termination or by raising an exception.

If closing the file raises an exception, then that exception will be raised by withFileAsInput rather than any exception raised by act.

withFileAsInputStartingAt Source

Arguments

:: Int64

starting index to seek to

-> FilePath

file to open

-> (InputStream ByteString -> IO a)

function to run

-> IO a 

Like withFileAsInput, but seeks to the specified byte offset before attaching the given file descriptor to the InputStream.

unsafeWithFileAsInputStartingAt Source

Arguments

:: Int64

starting index to seek to

-> FilePath

file to open

-> (InputStream ByteString -> IO a)

function to run

-> IO a 

Like withFileAsInputStartingAt, except that the ByteString emitted by the created InputStream may reuse its buffer. You may only use this function if you do not retain references to the generated bytestrings emitted.

withFileAsOutput Source

Arguments

:: FilePath

file to open

-> (OutputStream ByteString -> IO a)

function to run

-> IO a 

Open a file for writing and attaches an OutputStream for you to write to. The file will be closed on error or completion of your action.

withFileAsOutputExt Source

Arguments

:: FilePath

file to open

-> IOMode

mode to write in

-> BufferMode

should we buffer the output?

-> (OutputStream ByteString -> IO a)

function to run

-> IO a 

Like withFileAsOutput, but allowing you control over the output file mode and buffering behaviour.