system-fileio-0.1: High-level filesystem interaction

Portabilityportable
Maintainerjmillikin@gmail.com

System.File

Contents

Description

Simple FilePath‐aware wrappers around standard System.IO computations. See the linked documentation for each computation for details on exceptions and operating system interaction.

Synopsis

Documentation

type Handle = HandleSource

Re‐exported for convenience.

type Mode = IOModeSource

Re‐exported for convenience.

Binary files

openFile :: FilePath -> Mode -> IO HandleSource

Open a file in binary mode, and return an open Handle. The Handle should be hClosed when it is no longer needed.

withFile is easier to use, because it will handle the Handle’s lifetime automatically.

See: openBinaryFile

withFile :: FilePath -> Mode -> (Handle -> IO a) -> IO aSource

Open a file in binary mode, and pass its Handle to a provided computation. The Handle will be automatically closed when the computation returns.

See: withBinaryFile

readFile :: FilePath -> IO ByteStringSource

Read in the entire contents of a binary file.

See: readFile

writeFile :: FilePath -> ByteString -> IO ()Source

Replace the entire contents of a binary file with the provided ByteString.

See: writeFile

appendFile :: FilePath -> ByteString -> IO ()Source

Append a ByteString to a file. If the file does not exist, it will be created.

See: appendFile

Text files

openTextFile :: FilePath -> Mode -> IO HandleSource

Open a file in text mode, and return an open Handle. The Handle should be hClosed when it is no longer needed.

withTextFile is easier to use, because it will handle the Handle’s lifetime automatically.

See: openFile

withTextFile :: FilePath -> Mode -> (Handle -> IO a) -> IO aSource

Open a file in text mode, and pass its Handle to a provided computation. The Handle will be automatically closed when the computation returns.

See: withFile

readTextFile :: FilePath -> IO TextSource

Read in the entire contents of a text file.

See: readFile

writeTextFile :: FilePath -> Text -> IO ()Source

Replace the entire contents of a text file with the provided Text.

See: writeFile

appendTextFile :: FilePath -> Text -> IO ()Source

Append Text to a file. If the file does not exist, it will be created.

See: appendFile