LambdaHack-0.6.2.0: A game engine library for roguelike dungeon crawlers

Safe HaskellNone
LanguageHaskell2010

Game.LambdaHack.Common.File

Description

Saving/loading with serialization and compression.

Synopsis

Documentation

encodeEOF :: Binary a => FilePath -> a -> 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 a => FilePath -> IO a 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 the function returns.

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 #

The operation doesFileExist returns True if the argument file exists and is not a directory, and False otherwise.

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.

readFile :: FilePath -> IO String #

The readFile function reads a file and returns the contents of the file as a string. The file is read lazily, on demand, as with getContents.

renameFile :: FilePath -> FilePath -> IO () #

renameFile old new changes the name of an existing file system object from old to new. If the new object already exists, it is atomically replaced by the old object. Neither path may refer to an existing directory. A conformant implementation need not support renaming files in all situations (e.g. renaming across different physical devices), but the constraints must be documented.

The operation may fail with:

  • HardwareFault A physical I/O error has occurred. [EIO]
  • InvalidArgument Either operand is not a valid file name. [ENAMETOOLONG, ELOOP]
  • isDoesNotExistError / NoSuchThing The original file does not exist, or there is no path to the target. [ENOENT, ENOTDIR]
  • isPermissionError / PermissionDenied The process has insufficient privileges to perform the operation. [EROFS, EACCES, EPERM]
  • ResourceExhausted Insufficient resources are available to perform the operation. [EDQUOT, ENOSPC, ENOMEM, EMLINK]
  • UnsatisfiedConstraints Implementation-dependent constraints are not satisfied. [EBUSY]
  • UnsupportedOperation The implementation does not support renaming in this situation. [EXDEV]
  • InappropriateType Either path refers to an existing directory. [ENOTDIR, EISDIR, EINVAL, EEXIST, ENOTEMPTY]