Commit 47b70b7d authored by Pascal Stücker's avatar Pascal Stücker

Add hSetBinaryMode to allow binary IO

parent 7384be8c
......@@ -13,7 +13,8 @@ module IO(Handle,IOMode(..),SeekMode(..),stdin,stdout,stderr,
hWaitForInputOrMsg,hWaitForInputsOrMsg,hReady,
hGetChar,hGetLine,hGetContents,getContents,
hPutChar,hPutStr,hPutStrLn,hPrint,
hIsReadable,hIsWritable,hIsTerminalDevice) where
hIsReadable,hIsWritable,hIsTerminalDevice,
hSetBinaryMode ) where
--- The abstract type of a handle for a stream.
external data Handle -- internally defined
......@@ -242,3 +243,12 @@ hIsTerminalDevice h = prim_hIsTerminalDevice $# h
prim_hIsTerminalDevice :: Handle -> IO Bool
prim_hIsTerminalDevice external
--- Sets binary mode (<code>True</code>) or text mode (<code>False</code>)
--- for a handle. Binary mode avoids text encoding issues when working with
--- binary data. Text mode is the default and should be preferred for text
--- input/output.
hSetBinaryMode :: Handle -> Bool -> IO ()
hSetBinaryMode h b = (prim_hSetBinaryMode $# h) $# b
prim_hSetBinaryMode :: Handle -> Bool -> IO ()
prim_hSetBinaryMode external
\ No newline at end of file
......@@ -120,3 +120,8 @@ external_d_C_prim_hIsTerminalDevice :: C_Handle -> Cover -> ConstStore
-> Curry_Prelude.C_IO Curry_Prelude.C_Bool
external_d_C_prim_hIsTerminalDevice h _ _ =
toCurry (hIsTerminalDevice . outputHandle) h
external_d_C_prim_hSetBinaryMode :: C_Handle -> Curry_Prelude.C_Bool -> Cover -> ConstStore -> Curry_Prelude.C_IO Curry_Prelude.OP_Unit
external_d_C_prim_hSetBinaryMode h b _ _ = do
toCurry (hSetBinaryMode . inputHandle) h b
toCurry (hSetBinaryMode . outputHandle) h b
\ No newline at end of file
......@@ -69,4 +69,8 @@
<library>prim_io</library>
<entry>prim_hIsTerminalDevice</entry>
</primitive>
<primitive name="prim_hSetBinaryMode" arity="2">
<library>prim_io</library>
<entry>prim_hSetBinaryMode</entry>
</primitive>
</primitives>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment