unix-bytestring-0.3.7: Unix/Posix-specific functions for ByteStrings.

Portabilitynon-portable (requires POSIX.1, XPG4.2)
Stabilityexperimental
Maintainerwren@community.haskell.org
Safe HaskellNone

System.Posix.IO.ByteString.Lazy

Contents

Description

Provides a lazy-ByteString file-descriptor based I/O API, designed loosely after the String file-descriptor based I/O API in System.Posix.IO. The functions here wrap standard C implementations of the functions specified by the ISO/IEC 9945-1:1990 (``POSIX.1'') and X/Open Portability Guide Issue 4, Version 2 (``XPG4.2'') specifications.

These functions are provided mainly as a convenience to avoid boilerplate code converting between lazy ByteString and strict [ByteString]. It may be depricated in the future.

Synopsis

I/O with file descriptors

Reading

fdReadSource

Arguments

:: Fd 
-> ByteCount

How many bytes to try to read.

-> IO ByteString

The bytes read.

Read data from an Fd and convert it to a ByteString. Throws an exception if this is an invalid descriptor, or EOF has been reached. This is a thin wrapper around fdRead.

fdPreadSource

Arguments

:: Fd 
-> ByteCount

How many bytes to try to read.

-> FileOffset

Where to read the data from.

-> IO ByteString

The bytes read.

Read data from a specified position in the Fd and convert it to a ByteString, without altering the position stored in the Fd. Throws an exception if this is an invalid descriptor, or EOF has been reached. This is a thin wrapper around fdPread.

Since: 0.3.1

Writing

fdWritesSource

Arguments

:: Fd 
-> ByteString

The string to write.

-> IO (ByteCount, ByteString)

How many bytes were actually written, and the remaining (unwritten) string.

Write a ByteString to an Fd. This function makes one write(2) system call per chunk, as per fdWrites.

fdWritevSource

Arguments

:: Fd 
-> ByteString

The string to write.

-> IO ByteCount

How many bytes were actually written.

Write a ByteString to an Fd. This function makes a single writev(2) system call, as per fdWritev.