libfuse3-0.1.1.0: A Haskell binding for libfuse-3.x
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.LibFuse3.Utils

Description

Miscellaneous utilities provided for convenience.

These can be used for general purpose and are not directly related to FUSE.

Synopsis

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

unErrno :: Errno -> CInt Source #

Unwraps the newtype Errno.

ioErrorToErrno :: IOError -> Maybe Errno Source #

Attempts to extract an Errno from an IOError assuming it is constructed with errnoToIOError (typically via throwErrno).

tryErrno :: IO a -> IO (Either Errno a) Source #

Catches an exception constructed with errnoToIOError and extracts Errno from it.

tryErrno_ :: IO a -> IO Errno Source #

Like tryErrno but discards the result of the original action.

If no exceptions, returns eOK.

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.

TimeSpec

timeSpecToPOSIXTime :: TimeSpec -> POSIXTime Source #

Converts a TimeSpec to a POSIXTime.

This is the same conversion as the unix package does (as of writing).