Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Miscellaneous utilities provided for convenience.
These can be used for general purpose and are not directly related to FUSE.
Synopsis
- testBitSet :: Bits a => a -> a -> Bool
- unErrno :: Errno -> CInt
- ioErrorToErrno :: IOError -> Maybe Errno
- throwErrnoOf :: String -> Errno -> IO a
- tryErrno :: IO a -> IO (Either Errno a)
- tryErrno_ :: IO a -> IO Errno
- tryErrno' :: IO a -> IO (Either Errno a)
- tryErrno_' :: IO a -> IO Errno
- pread :: Fd -> ByteCount -> FileOffset -> IO ByteString
- pwrite :: Fd -> ByteString -> FileOffset -> IO CSsize
- c_pread :: CInt -> Ptr a -> CSize -> COff -> IO CSsize
- c_pwrite :: CInt -> Ptr a -> CSize -> COff -> IO CSsize
- pokeCStringLen0 :: CStringLen -> String -> IO ()
- timeSpecToPOSIXTime :: TimeSpec -> POSIXTime
Bitsets
testBitSet :: Bits a => a -> a -> Bool Source #
testBitSet bits mask
is True
iff all bits in mask
are set in bits
.
testBitSet bits mask ≡ bits .&. mask == mask
Errno
ioErrorToErrno :: IOError -> Maybe Errno Source #
Attempts to extract an Errno
from an IOError
assuming it is
constructed with errnoToIOError
(typically via throwErrno
).
Like throwErrno
but takes an Errno
as a parameter instead of reading from getErrno
.
This is an inverse of tryErrno
:
tryErrno (throwErrnoOf _ e) ≡ pure (Left e)
tryErrno :: IO a -> IO (Either Errno a) Source #
Catches an exception constructed with errnoToIOError
and extracts Errno
from it.
File I/O
pread :: Fd -> ByteCount -> FileOffset -> IO ByteString Source #
Reads from a file descriptor at a given offset.
Fewer bytes may be read than requested.
On error, throws an IOError
corresponding to the errno.
pwrite :: Fd -> ByteString -> FileOffset -> IO CSsize Source #
Writes to a file descriptor at a given offset.
Returns the number of bytes written. Fewer bytes may be written than requested.
On error, throws an IOError
corresponding to the errno.
Marshalling strings
pokeCStringLen0 :: CStringLen -> String -> IO () Source #
Marshals a Haskell string into a NUL terminated C string in a locale-dependent way.
Does withCStringLen
and copies it into the destination buffer.
The Haskell string should not contain NUL characters.
If the destination buffer is not long enough to hold the source string, it is truncated and a NUL byte is inserted at the end of the buffer.