{-# LINE 1 "libraries/unix/System/Posix/Fcntl.hsc" #-}
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE Safe #-}
module System.Posix.Fcntl (
Advice(..), fileAdvise,
fileAllocate,
fileGetCaching,
fileSetCaching,
) where
import Foreign.C
import System.Posix.Types
{-# LINE 34 "libraries/unix/System/Posix/Fcntl.hsc" #-}
import System.IO.Error ( ioeSetLocation )
import GHC.IO.Exception ( unsupportedOperation )
{-# LINE 37 "libraries/unix/System/Posix/Fcntl.hsc" #-}
{-# LINE 42 "libraries/unix/System/Posix/Fcntl.hsc" #-}
{-# LINE 46 "libraries/unix/System/Posix/Fcntl.hsc" #-}
data Advice
= AdviceNormal
| AdviceRandom
| AdviceSequential
| AdviceWillNeed
| AdviceDontNeed
| AdviceNoReuse
deriving Advice -> Advice -> Bool
(Advice -> Advice -> Bool)
-> (Advice -> Advice -> Bool) -> Eq Advice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Advice -> Advice -> Bool
== :: Advice -> Advice -> Bool
$c/= :: Advice -> Advice -> Bool
/= :: Advice -> Advice -> Bool
Eq
fileAdvise :: Fd -> FileOffset -> FileOffset -> Advice -> IO ()
{-# LINE 88 "libraries/unix/System/Posix/Fcntl.hsc" #-}
fileAdvise :: Fd -> FileOffset -> FileOffset -> Advice -> IO ()
fileAdvise Fd
_ FileOffset
_ FileOffset
_ Advice
_ = () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
{-# LINE 90 "libraries/unix/System/Posix/Fcntl.hsc" #-}
fileAllocate :: Fd -> FileOffset -> FileOffset -> IO ()
{-# LINE 101 "libraries/unix/System/Posix/Fcntl.hsc" #-}
fileAllocate fd off len = do
ret <- c_posix_fallocate (fromIntegral fd) (fromIntegral off) (fromIntegral len)
if ret == 0
then pure ()
else ioError (errnoToIOError "fileAllocate" (Errno ret) Nothing Nothing)
foreign import capi safe "fcntl.h posix_fallocate"
c_posix_fallocate :: CInt -> COff -> COff -> IO CInt
{-# LINE 115 "libraries/unix/System/Posix/Fcntl.hsc" #-}
fileGetCaching :: Fd -> IO Bool
{-# LINE 143 "libraries/unix/System/Posix/Fcntl.hsc" #-}
{-# WARNING fileGetCaching
"operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_O_DIRECT@)" #-}
fileGetCaching :: Fd -> IO Bool
fileGetCaching Fd
_ = IOError -> IO Bool
forall a. IOError -> IO a
ioError (IOError -> String -> IOError
ioeSetLocation IOError
unsupportedOperation String
"fileGetCaching")
{-# LINE 147 "libraries/unix/System/Posix/Fcntl.hsc" #-}
fileSetCaching :: Fd -> Bool -> IO ()
{-# LINE 179 "libraries/unix/System/Posix/Fcntl.hsc" #-}
{-# WARNING fileSetCaching
"operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_O_DIRECT || HAVE_F_NOCACHE @)" #-}
fileSetCaching :: Fd -> Bool -> IO ()
fileSetCaching Fd
_ Bool
_ = IOError -> IO ()
forall a. IOError -> IO a
ioError (IOError -> String -> IOError
ioeSetLocation IOError
unsupportedOperation String
"fileSetCaching")
{-# LINE 183 "libraries/unix/System/Posix/Fcntl.hsc" #-}