LambdaHack-0.9.5.0: A game engine library for tactical squad ASCII roguelike dungeon crawlers
Safe HaskellNone
LanguageHaskell2010

Game.LambdaHack.Common.File

Description

Saving/loading to files, with serialization and compression.

Synopsis

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.

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.