module Data.Streaming.FileRead
( ReadHandle
, openFile
, closeFile
, readChunk
) where
#if WINDOWS
import System.Win32File
#else
import qualified System.IO as IO
import qualified Data.ByteString as S
import Data.ByteString.Lazy.Internal (defaultChunkSize)
newtype ReadHandle = ReadHandle IO.Handle
openFile :: FilePath -> IO ReadHandle
openFile fp = ReadHandle `fmap` IO.openBinaryFile fp IO.ReadMode
closeFile :: ReadHandle -> IO ()
closeFile (ReadHandle h) = IO.hClose h
readChunk :: ReadHandle -> IO S.ByteString
readChunk (ReadHandle h) = S.hGetSome h defaultChunkSize
#endif