GHC.IO.FD

base-4.13.0.0: Basic libraries

Copyright | (c) The University of Glasgow 1994-2008
License | see libraries/base/LICENSE
Maintainer | libraries@haskell.org
Stability | internal
Portability | non-portable
Safe Haskell | Trustworthy
Language | Haskell2010

GHC.IO.FD

Description

Raw read/write operations on file descriptors

Synopsis

- data FD = FD {
  - fdFD :: !CInt
  - fdIsNonBlocking :: !Int
  }
- openFile :: FilePath -> IOMode -> Bool -> IO (FD, IODeviceType)
- mkFD :: CInt -> IOMode -> Maybe (IODeviceType, CDev, CIno) -> Bool -> Bool -> IO (FD, IODeviceType)
- release :: FD -> IO ()
- setNonBlockingMode :: FD -> Bool -> IO FD
- readRawBufferPtr :: String -> FD -> Ptr Word8 -> Int -> CSize -> IO Int
- readRawBufferPtrNoBlock :: String -> FD -> Ptr Word8 -> Int -> CSize -> IO Int
- writeRawBufferPtr :: String -> FD -> Ptr Word8 -> Int -> CSize -> IO CInt
- stdin :: FD
- stdout :: FD
- stderr :: FD

# Documentation

data FD Source #

Constructors

FD |
Fields fdFD :: !CInt fdIsNonBlocking :: !Int

#### Instances

Instances details

Show FD # | Since: base-4.1.0.0
Instance details Defined in GHC.IO.FD Methods showsPrec :: Int -> FD -> ShowS Source # show :: FD -> String Source # showList :: [FD] -> ShowS Source #
IODevice FD # | Since: base-4.1.0.0
Instance details Defined in GHC.IO.FD Methods ready :: FD -> Bool -> Int -> IO Bool Source # close :: FD -> IO () Source # isTerminal :: FD -> IO Bool Source # isSeekable :: FD -> IO Bool Source # seek :: FD -> SeekMode -> Integer -> IO () Source # tell :: FD -> IO Integer Source # getSize :: FD -> IO Integer Source # setSize :: FD -> Integer -> IO () Source # setEcho :: FD -> Bool -> IO () Source # getEcho :: FD -> IO Bool Source # setRaw :: FD -> Bool -> IO () Source # devType :: FD -> IO IODeviceType Source # dup :: FD -> IO FD Source # dup2 :: FD -> FD -> IO FD Source #
RawIO FD # | Since: base-4.1.0.0
Instance details Defined in GHC.IO.FD Methods read :: FD -> Ptr Word8 -> Int -> IO Int Source # readNonBlocking :: FD -> Ptr Word8 -> Int -> IO (Maybe Int) Source # write :: FD -> Ptr Word8 -> Int -> IO () Source # writeNonBlocking :: FD -> Ptr Word8 -> Int -> IO Int Source #
BufferedIO FD # | Since: base-4.1.0.0
Instance details Defined in GHC.IO.FD Methods newBuffer :: FD -> BufferState -> IO (Buffer Word8) Source # fillReadBuffer :: FD -> Buffer Word8 -> IO (Int, Buffer Word8) Source # fillReadBuffer0 :: FD -> Buffer Word8 -> IO (Maybe Int, Buffer Word8) Source # emptyWriteBuffer :: FD -> Buffer Word8 -> IO (Buffer Word8) Source # flushWriteBuffer :: FD -> Buffer Word8 -> IO (Buffer Word8) Source # flushWriteBuffer0 :: FD -> Buffer Word8 -> IO (Int, Buffer Word8) Source #

openFile Source #

Arguments

:: FilePath | file to open
-> IOMode | mode in which to open the file
-> Bool | open the file in non-blocking mode?
-> IO (FD, IODeviceType) |

Open a file and make an `FD` for it. Truncates the file to zero size when the `IOMode` is `WriteMode`.

mkFD Source #

Arguments

:: CInt |
-> IOMode |
-> Maybe (IODeviceType, CDev, CIno) |
-> Bool | is a socket (on Windows)
-> Bool | is in non-blocking mode on Unix
-> IO (FD, IODeviceType) |

Make a `FD` from an existing file descriptor. Fails if the FD refers to a directory. If the FD refers to a file, `mkFD` locks the file according to the Haskell 2010 single writer/multiple reader locking semantics (this is why we need the `IOMode` argument too).

release :: FD -> IO () Source #

setNonBlockingMode :: FD -> Bool -> IO FD Source #

readRawBufferPtr :: String -> FD -> Ptr Word8 -> Int -> CSize -> IO Int Source #

readRawBufferPtrNoBlock :: String -> FD -> Ptr Word8 -> Int -> CSize -> IO Int Source #

writeRawBufferPtr :: String -> FD -> Ptr Word8 -> Int -> CSize -> IO CInt Source #

stdin :: FD Source #

stdout :: FD Source #

stderr :: FD Source #