-#ifndef __HUGS__ /* Hugs' Prelude doesn't need this */
-hFillBufBA :: Handle -> MutableByteArray RealWorld a -> Int -> IO Int
-hFillBufBA handle buf sz
- | sz <= 0 = ioError (IOError (Just handle)
- InvalidArgument
- "hFillBufBA"
- ("illegal buffer size " ++ showsPrec 9 sz [])) -- 9 => should be parens'ified.
- | otherwise = hFillBuf' sz 0
- where
- hFillBuf' sz len = do
- r <- mayBlockRead "hFillBufBA" handle (\fo -> readChunkBA fo buf len sz)
- if r >= sz || r == 0 -- r == 0 indicates EOF
- then return (len+r)
- else hFillBuf' (sz-r) (len+r)
-#endif
-
-hFillBuf :: Handle -> Addr -> Int -> IO Int
-hFillBuf handle buf sz
- | sz <= 0 = ioError (IOError (Just handle)
- InvalidArgument
- "hFillBuf"
- ("illegal buffer size " ++ showsPrec 9 sz []))
- -- 9 => should be parens'ified.
- | otherwise = hFillBuf' sz 0
- where
- hFillBuf' sz len = do
- r <- mayBlockRead "hFillBuf" handle (\fo -> readChunk fo buf len sz)
- if r >= sz || r == 0 -- r == 0 indicates EOF
- then return (len+r)
- else hFillBuf' (sz-r) (len+r)
-\end{code}
-
-The @hPutBuf hdl buf len@ action writes an already packed sequence of
-bytes to the file/channel managed by @hdl@ - non-standard.
-
-\begin{code}
-hPutBuf :: Handle -> Addr -> Int -> IO ()
-hPutBuf handle buf sz
- | sz <= 0 = ioError (IOError (Just handle)
- InvalidArgument
- "hPutBuf"
- ("illegal buffer size " ++ showsPrec 9 sz []))
- -- 9 => should be parens'ified.
- | otherwise = hPutBuf' sz 0
- where
- hPutBuf' sz len = do
- r <- mayBlockWrite "hPutBuf" handle (\fo -> writeBuf fo buf len sz)
- if r >= sz
- then return ()
- else hPutBuf' (sz-r) (len+r) -- <= sz indicates blocking
-
-#ifndef __HUGS__ /* An_ one Hugs doesn't provide */
-hPutBufBA :: Handle -> MutableByteArray RealWorld a -> Int -> IO ()
-hPutBufBA handle buf sz
- | sz <= 0 = ioError (IOError (Just handle)
- InvalidArgument
- "hPutBufBA"
- ("illegal buffer size " ++ showsPrec 9 sz []))
- -- 9 => should be parens'ified.
- | otherwise = hPutBuf' sz 0
- where
- hPutBuf' sz len = do
- r <- mayBlockWrite "hPutBufBA" handle (\fo -> writeBufBA fo buf len sz)
- if r >= sz
- then return ()
- else hPutBuf' (sz-r) (len+r) -- <= sz indicates blocking
-#endif