| |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
Description | |||||||||||||||||||||||||||||||||
This module provides various helpful utilities for dealing with I/O. Important note: binary functions are not supported in all Haskell implementations. Do not import or use this module unless you know you are using an implementation that supports them. At this time, here is the support status:
Non-binary functions may be found in MissingH.IO. Written by John Goerzen, jgoerzen@complete.org | |||||||||||||||||||||||||||||||||
Synopsis | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
Entire File/Handle Utilities | |||||||||||||||||||||||||||||||||
Opened Handle Data Copying | |||||||||||||||||||||||||||||||||
hBlockCopy :: Int -> Handle -> Handle -> IO () | |||||||||||||||||||||||||||||||||
Copies everything from the input handle to the output handle using binary blocks of the given size. This is actually a beautiful implementation: hBlockCopy bs hin hout = hBlockInteract bs hin hout id (id is the built-in Haskell function that just returns whatever is given to it) | |||||||||||||||||||||||||||||||||
blockCopy :: Int -> IO () | |||||||||||||||||||||||||||||||||
Copies from stdin to stdout using binary blocks of the given size. An alias for hBlockCopy over stdin and stdout | |||||||||||||||||||||||||||||||||
Disk File Data Copying | |||||||||||||||||||||||||||||||||
copyFileBlocksToFile :: Int -> FilePath -> FilePath -> IO () | |||||||||||||||||||||||||||||||||
Copies one filename to another in binary mode. Please note that the Unix permission bits on the output file cannot be set due to a limitation of the Haskell openBinaryFile function. Therefore, you may need to adjust those bits after the copy yourself. This function is implemented using hBlockCopy internally. | |||||||||||||||||||||||||||||||||
Binary Single-Block I/O | |||||||||||||||||||||||||||||||||
hPutBufStr :: Handle -> String -> IO () | |||||||||||||||||||||||||||||||||
As a wrapper around the standard function hPutBuf, this function takes a standard Haskell String instead of the far less convenient 'Ptr a'. The entire contents of the string will be written as a binary buffer using hPutBuf. The length of the output will be the length of the string. | |||||||||||||||||||||||||||||||||
putBufStr :: String -> IO () | |||||||||||||||||||||||||||||||||
An alias for hPutBufStr stdout | |||||||||||||||||||||||||||||||||
hGetBufStr :: Handle -> Int -> IO String | |||||||||||||||||||||||||||||||||
As a wrapper around the standard function hGetBuf, this function returns a standard Haskell string instead of modifying a 'Ptr a' buffer. The length is the maximum length to read and the semantice are the same as with hGetBuf; namely, the empty string is returned with EOF is reached, and any given read may read fewer bytes than the given length. | |||||||||||||||||||||||||||||||||
getBufStr :: Int -> IO String | |||||||||||||||||||||||||||||||||
An alias for hGetBufStr stdin | |||||||||||||||||||||||||||||||||
hFullGetBufStr :: Handle -> Int -> IO String | |||||||||||||||||||||||||||||||||
Like hGetBufStr, but guarantees that it will only return fewer than the requested number of bytes when EOF is encountered. | |||||||||||||||||||||||||||||||||
fullGetBufStr :: Int -> IO String | |||||||||||||||||||||||||||||||||
An alias for hFullGetBufStr stdin | |||||||||||||||||||||||||||||||||
Binary Multi-Block I/O | |||||||||||||||||||||||||||||||||
hGetBlocks :: Handle -> Int -> IO [String] | |||||||||||||||||||||||||||||||||
Returns a lazily-evaluated list of all blocks in the input file, as read by hGetBufStr. There will be no 0-length block in this list. The list simply ends at EOF. | |||||||||||||||||||||||||||||||||
getBlocks :: Int -> IO [String] | |||||||||||||||||||||||||||||||||
An alias for hGetBlocks stdin | |||||||||||||||||||||||||||||||||
hFullGetBlocks :: Handle -> Int -> IO [String] | |||||||||||||||||||||||||||||||||
Same as hGetBlocks, but using hFullGetBufStr underneath. | |||||||||||||||||||||||||||||||||
fullGetBlocks :: Int -> IO [String] | |||||||||||||||||||||||||||||||||
An alias for hFullGetBlocks stdin | |||||||||||||||||||||||||||||||||
Lazy Interaction | |||||||||||||||||||||||||||||||||
Binary Block-based | |||||||||||||||||||||||||||||||||
hBlockInteract :: Int -> Handle -> Handle -> ([String] -> [String]) -> IO () | |||||||||||||||||||||||||||||||||
Binary block-based interaction. This is useful for scenarios that take binary blocks, manipulate them in some way, and then write them out. Take a look at hBlockCopy for an example. The integer argument is the size of input binary blocks. This function uses hGetBlocks internally. | |||||||||||||||||||||||||||||||||
blockInteract :: Int -> ([String] -> [String]) -> IO () | |||||||||||||||||||||||||||||||||
An alias for hBlockInteract over stdin and stdout | |||||||||||||||||||||||||||||||||
hFullBlockInteract :: Int -> Handle -> Handle -> ([String] -> [String]) -> IO () | |||||||||||||||||||||||||||||||||
Same as hBlockInteract, but uses hFullGetBlocks instead of hGetBlocks internally. | |||||||||||||||||||||||||||||||||
fullBlockInteract :: Int -> ([String] -> [String]) -> IO () | |||||||||||||||||||||||||||||||||
An alias for hFullBlockInteract over stdin and stdout | |||||||||||||||||||||||||||||||||
Produced by Haddock version 0.6 |