System.Posix.IO

| Haskell Hierarchical Libraries (unix package) | Contents | Index
System.Posix.IO |
Portability | non-portable (requires POSIX)
Stability | provisional
Maintainer | libraries@haskell.org
Contents
Input / Output Standard file descriptors Opening and closing files Reading/writing data Seeking File options Locking Pipes Duplicating file descriptors Converting file descriptors to/from Handles
Description
POSIX IO support
Synopsis
stdInput :: Fd
stdOutput :: Fd
stdError :: Fd
data OpenMode
= ReadOnly
| WriteOnly
| ReadWrite
data OpenFileFlags = OpenFileFlags {
append :: Bool
exclusive :: Bool
noctty :: Bool
nonBlock :: Bool
trunc :: Bool
}
defaultFileFlags :: OpenFileFlags
openFd :: FilePath -> OpenMode -> Maybe FileMode -> OpenFileFlags -> IO Fd
createFile :: FilePath -> FileMode -> IO Fd
closeFd :: Fd -> IO ()
fdRead :: Fd -> ByteCount -> IO (String, ByteCount)
fdWrite :: Fd -> String -> IO ByteCount
fdSeek :: Fd -> SeekMode -> FileOffset -> IO FileOffset
data FdOption
= AppendOnWrite
| CloseOnExec
| NonBlockingRead
| SynchronousWrites
queryFdOption :: Fd -> FdOption -> IO Bool
setFdOption :: Fd -> FdOption -> Bool -> IO ()
type FileLock = (LockRequest, SeekMode, FileOffset, FileOffset)
data LockRequest
= ReadLock
| WriteLock
| Unlock
getLock :: Fd -> FileLock -> IO (Maybe (ProcessID, FileLock))
setLock :: Fd -> FileLock -> IO ()
waitToSetLock :: Fd -> FileLock -> IO ()
createPipe :: IO (Fd, Fd)
dup :: Fd -> IO Fd
dupTo :: Fd -> Fd -> IO Fd
handleToFd :: Handle -> IO Fd
fdToHandle :: Fd -> IO Handle
Input / Output
Standard file descriptors
stdInput :: Fd
stdOutput :: Fd
stdError :: Fd
Opening and closing files
data OpenMode
Constructors
ReadOnly |
WriteOnly |
ReadWrite |
data OpenFileFlags
Constructors
OpenFileFlags |
append :: Bool |
exclusive :: Bool |
noctty :: Bool |
nonBlock :: Bool |
trunc :: Bool |
defaultFileFlags :: OpenFileFlags
openFd :: FilePath -> OpenMode -> Maybe FileMode -> OpenFileFlags -> IO Fd
createFile :: FilePath -> FileMode -> IO Fd
closeFd :: Fd -> IO ()
Reading/writing data
Programmers using the `fdRead` and `fdWrite` API should be aware that EAGAIN exceptions may occur for non-blocking IO!
fdRead :: Fd -> ByteCount -> IO (String, ByteCount)
fdWrite :: Fd -> String -> IO ByteCount
Seeking
fdSeek :: Fd -> SeekMode -> FileOffset -> IO FileOffset
File options
data FdOption
Constructors
AppendOnWrite |
CloseOnExec |
NonBlockingRead |
SynchronousWrites |
queryFdOption :: Fd -> FdOption -> IO Bool
setFdOption :: Fd -> FdOption -> Bool -> IO ()
Locking
type FileLock = (LockRequest, SeekMode, FileOffset, FileOffset)
data LockRequest
Constructors
ReadLock |
WriteLock |
Unlock |
getLock :: Fd -> FileLock -> IO (Maybe (ProcessID, FileLock))
setLock :: Fd -> FileLock -> IO ()
waitToSetLock :: Fd -> FileLock -> IO ()
Pipes
createPipe :: IO (Fd, Fd)
The `createPipe` function creates a pair of connected file descriptors. The first component is the fd to read from, the second is the write end. Although pipes may be bidirectional, this behaviour is not portable and programmers should use two separate pipes for this purpose.
Duplicating file descriptors
dup :: Fd -> IO Fd
dupTo :: Fd -> Fd -> IO Fd
Converting file descriptors to/from Handles
handleToFd :: Handle -> IO Fd
fdToHandle :: Fd -> IO Handle
Produced by Haddock version 0.6