1{-# LANGUAGE CPP #-} 2 3module Network.Sendfile.Types where 4 5#ifdef VERSION_unix 6import qualified Data.ByteString as B 7 8import qualified System.Posix.IO as P 9import qualified System.Posix.IO.ByteString as PB 10import qualified System.Posix.Types as P 11#endif 12 13-- | 14-- File range for 'sendfile'. 15 16data FileRange = EntireFile 17 | PartOfFile { 18 rangeOffset :: Integer 19 , rangeLength :: Integer 20 } 21 22-- To avoid build error in windows 23#ifdef VERSION_unix 24 25-- | 'openFd's signature changed in @unix-2.8@. This is a portable wrapper. 26openFd :: FilePath -> P.OpenMode -> P.OpenFileFlags -> IO P.Fd 27#if MIN_VERSION_unix(2,8,0) 28openFd path mode flags = P.openFd path mode flags 29#else 30openFd path mode flags = P.openFd path mode Nothing flags 31#endif 32 33-- | 'openFd's signature changed in @unix-2.8@. This is a portable wrapper. 34openFdBS :: B.ByteString -> P.OpenMode -> P.OpenFileFlags -> IO P.Fd 35#if MIN_VERSION_unix(2,8,0) 36openFdBS path mode flags = PB.openFd path mode flags 37#else 38openFdBS path mode flags = PB.openFd path mode Nothing flags 39#endif 40 41#endif 42