Safe Haskell | None |
---|---|
Language | Haskell2010 |
Game.LambdaHack.Common.File
Description
Saving/loading to files, with serialization and compression.
Synopsis
- encodeEOF :: Binary b => FilePath -> Version -> b -> IO ()
- strictDecodeEOF :: Binary b => FilePath -> IO (Version, b)
- tryCreateDir :: FilePath -> IO ()
- doesFileExist :: FilePath -> IO Bool
- tryWriteFile :: FilePath -> String -> IO ()
- readFile :: FilePath -> IO String
- renameFile :: FilePath -> FilePath -> IO ()
Documentation
encodeEOF :: Binary b => FilePath -> Version -> b -> IO () Source #
Serialize, compress and save data with an EOF marker.
The OK
is used as an EOF marker to ensure any apparent problems with
corrupted files are reported to the user ASAP.
strictDecodeEOF :: Binary b => FilePath -> IO (Version, b) Source #
Read, decompress and deserialize data with an EOF marker.
The OK
EOF marker ensures any easily detectable file corruption
is discovered and reported before any value is decoded from
the second component and before the file handle is closed.
OTOH, binary encoding corruption is not discovered until a version
check elswere ensures that binary formats are compatible.
tryCreateDir :: FilePath -> IO () Source #
Try to create a directory, if it doesn't exist. We catch exceptions in case many clients try to do the same thing at the same time.
doesFileExist :: FilePath -> IO Bool #
tryWriteFile :: FilePath -> String -> IO () Source #
Try to write a file, given content, if the file not already there. We catch exceptions in case many clients try to do the same thing at the same time.
renameFile :: FilePath -> FilePath -> IO () #