| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Game.LambdaHack.Common.File
Description
Saving/loading to files, with serialization and compression.
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 () #
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.renameFile old new
The operation may fail with:
HardwareFaultA physical I/O error has occurred.[EIO]InvalidArgumentEither operand is not a valid file name.[ENAMETOOLONG, ELOOP]isDoesNotExistError/NoSuchThingThe original file does not exist, or there is no path to the target.[ENOENT, ENOTDIR]isPermissionError/PermissionDeniedThe process has insufficient privileges to perform the operation.[EROFS, EACCES, EPERM]ResourceExhaustedInsufficient resources are available to perform the operation.[EDQUOT, ENOSPC, ENOMEM, EMLINK]UnsatisfiedConstraintsImplementation-dependent constraints are not satisfied.[EBUSY]UnsupportedOperationThe implementation does not support renaming in this situation.[EXDEV]InappropriateTypeEither path refers to an existing directory.[ENOTDIR, EISDIR, EINVAL, EEXIST, ENOTEMPTY]