Module BinaryFile

Library to support reading/writing binary files.

Author: Michael Hanus

Version: June 2018

Summary of exported operations:

openBinaryFile :: String -> IOMode -> IO Handle   
Like openFile, but open the file in binary mode.
hGetByte :: Handle -> IO Int   
Reads a byte from an input handle associated to a binary stream and returns it.
hPutByte :: Handle -> Int -> IO ()   
Puts a byte to an output handle associated to a binary stream.
hGetBinaryContents :: Handle -> IO [Int]   
Reads the complete contents from an input handle and closes the input handle before returning the contents.

Exported operations:

openBinaryFile :: String -> IOMode -> IO Handle   

Like openFile, but open the file in binary mode. Thus, no translation of character is performed when reading or writing a file. Returns a handle to read and write the binary stream (e.g., with operations hGetByte and hPutByte).

hGetByte :: Handle -> IO Int   

Reads a byte from an input handle associated to a binary stream and returns it. Throws an error if the end of file has been reached or the stream is not binary.

hPutByte :: Handle -> Int -> IO ()   

Puts a byte to an output handle associated to a binary stream.

hGetBinaryContents :: Handle -> IO [Int]   

Reads the complete contents from an input handle and closes the input handle before returning the contents.