Holumbus-Distribution-0.0.1: intra- and inter-program communicationSource codeContentsIndex
Holumbus.Common.FileHandling
Portabilityportable
Stabilityexperimental
MaintainerStefan Schmidt (stefanschmidt@web.de)
Contents
xml files
lists in binary files
bytestring file handling
string file handling
Description

Version : 0.1

Some nice helper functions for strict file writing, appending and reading. All read-functions are strict, in the sense that the whole file is read at once and the content is stored into memory. So you won't have any semi-closed handles which might bring you in trouble from time to time. The files are immedialty closed after the reading. This Module can handle four filetypes: XML-Files, List-Files, Binary-Files and Text-Files.

XML-Files: Normal textfiles, but the content is stored as a xml-representation. For the pickling, we use the HXT-Library (see http://www.fh-wedel.de/~si/HXmlToolbox/)

List-Files: Binary-Files, which store a list of data-objects. The main difference between Binary-Files and List-Files is, that you can append data to a List-File which will be automatically concatenated to the existing list. If you try this with a normal Binary-File, you'll get only the original list and the appended data will be lost.

Binary-Files: Normal binary files, for the encoding and decoding, we use the Haskell binary-package.

Text-Files: Normal text files.

Synopsis
loadFromXmlFile :: XmlPickler a => FilePath -> IO a
saveToXmlFile :: XmlPickler a => FilePath -> a -> IO ()
writeToListFile :: Binary a => FilePath -> [a] -> IO ()
appendToListFile :: Binary a => FilePath -> [a] -> IO ()
readFromListFile :: Binary a => FilePath -> IO [a]
parseByteStringToList :: Binary a => ByteString -> [a]
writeToBinFile :: FilePath -> ByteString -> IO ()
appendToBinFile :: FilePath -> ByteString -> IO ()
readFromBinFile :: FilePath -> IO ByteString
writeToTextFile :: FilePath -> String -> IO ()
appendToTextFile :: FilePath -> String -> IO ()
readFromTextFile :: FilePath -> IO String
xml files
loadFromXmlFile :: XmlPickler a => FilePath -> IO aSource
Loads an XML-File and parses the content to a specified datatype.
saveToXmlFile :: XmlPickler a => FilePath -> a -> IO ()Source
Converts a dataset to XML and saves the XML-string into a file.
lists in binary files
writeToListFile :: Binary a => FilePath -> [a] -> IO ()Source
Writes data to a list file.
appendToListFile :: Binary a => FilePath -> [a] -> IO ()Source
Appends data to a list file.
readFromListFile :: Binary a => FilePath -> IO [a]Source
reads from a list file.
parseByteStringToList :: Binary a => ByteString -> [a]Source
You'll need this function, if you read the files a a normal binary file, but the content itself is a list. This function encodes the bytestring into a list of the specified datatype.
bytestring file handling
writeToBinFile :: FilePath -> ByteString -> IO ()Source
Write data to a binary file.
appendToBinFile :: FilePath -> ByteString -> IO ()Source
Append data to a binary file, this doesn't mean, that the contents are really concatenated when you read the file.
readFromBinFile :: FilePath -> IO ByteStringSource
Reads the data from a binary file as a bytestring.
string file handling
writeToTextFile :: FilePath -> String -> IO ()Source
Writes a sting to a text file.
appendToTextFile :: FilePath -> String -> IO ()Source
Appends a string to a text file.
readFromTextFile :: FilePath -> IO StringSource
Strict file reading by Simon Marlow. found on http://users.aber.ac.uk/afc/stricthaskell.html
Produced by Haddock version 2.4.2