Portability | non-portable (requires POSIX.1, XPG4.2) |
---|---|
Stability | experimental |
Maintainer | wren@community.haskell.org |
Safe Haskell | None |
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 [
. It may be depricated in the future.
ByteString
]
- fdRead :: Fd -> ByteCount -> IO ByteString
- fdPread :: Fd -> ByteCount -> FileOffset -> IO ByteString
- fdWrites :: Fd -> ByteString -> IO (ByteCount, ByteString)
- fdWritev :: Fd -> ByteString -> IO ByteCount
I/O with file descriptors
Reading
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
.
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
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
.
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
.