module Network.Socket.SendFile.Util
( wrapSendFile'
) where
wrapSendFile' :: Integral i => (a -> b -> i -> i -> i -> IO c) -> a -> b -> Integer -> Integer -> Integer -> IO c
wrapSendFile' :: (a -> b -> i -> i -> i -> IO c)
-> a -> b -> Integer -> Integer -> Integer -> IO c
wrapSendFile' a -> b -> i -> i -> i -> IO c
fun a
outp b
inp Integer
blockSize Integer
off Integer
count
| Integer
count Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Integer
0 = [Char] -> IO c
forall a. HasCallStack => [Char] -> a
error [Char]
"SendFile - count must be a positive integer"
| (Integer
count Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
/= Integer
0) Bool -> Bool -> Bool
&& (Integer
blockSize Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= Integer
0) = [Char] -> IO c
forall a. HasCallStack => [Char] -> a
error [Char]
"SendFile - blockSize must be a positive integer greater than 1"
| Integer
off Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Integer
0 = [Char] -> IO c
forall a. HasCallStack => [Char] -> a
error [Char]
"SendFile - offset must be a positive integer"
| Bool
otherwise = a -> b -> i -> i -> i -> IO c
fun a
outp b
inp (Integer -> i
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
blockSize) (Integer -> i
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
off) (Integer -> i
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
count)