darcs-2.18.5: a distributed, interactive, smart revision control system

Safe Haskell | None
Language | Haskell2010

Darcs.Util.Lock

Synopsis

- withLock :: String -> IO a -> IO a
- withLockCanFail :: String -> IO a -> IO (Either () a)
- environmentHelpLocks :: ([String], [String])
- withTempDir :: FilePath -> (AbsolutePath -> IO a) -> IO a
- withPermDir :: FilePath -> (AbsolutePath -> IO a) -> IO a
- withDelayedDir :: FilePath -> (AbsolutePath -> IO a) -> IO a
- withNamedTemp :: FilePath -> (FilePath -> IO a) -> IO a
- writeBinFile :: FilePathLike p => p -> ByteString -> IO ()
- writeTextFile :: FilePathLike p => p -> String -> IO ()
- writeDocBinFile :: FilePathLike p => p -> Doc -> IO ()
- appendBinFile :: FilePathLike p => p -> ByteString -> IO ()
- appendTextFile :: FilePathLike p => p -> String -> IO ()
- appendDocBinFile :: FilePathLike p => p -> Doc -> IO ()
- readBinFile :: FilePathLike p => p -> IO ByteString
- readTextFile :: FilePathLike p => p -> IO [String]
- readDocBinFile :: FilePathLike p => p -> IO Doc
- writeAtomicFilePS :: FilePathLike p => p -> ByteString -> IO ()
- gzWriteAtomicFilePS :: FilePathLike p => p -> ByteString -> IO ()
- gzWriteAtomicFilePSs :: FilePathLike p => p -> [ByteString] -> IO ()
- gzWriteDocFile :: FilePathLike p => p -> Doc -> IO ()
- removeFileMayNotExist :: FilePathLike p => p -> IO ()
- maybeRelink :: String -> String -> IO Bool
- tempdirLoc :: IO FilePath
- environmentHelpTmpdir :: ([String], [String])
- environmentHelpKeepTmpdir :: ([String], [String])
- addToErrorLoc :: IOException -> String -> IOException
- withNewDirectory :: FilePath -> IO () -> IO ()

# Documentation

withLock :: String -> IO a -> IO a #

withLockCanFail :: String -> IO a -> IO (Either () a) #

Tries to perform some task if it can obtain the lock, Otherwise, just gives up without doing the task

environmentHelpLocks :: ([String], [String]) #

withTempDir :: FilePath -> (AbsolutePath -> IO a) -> IO a #

`withTempDir` creates a temporary directory, runs the action and then removes the directory. The location of that directory is determined by the contents of _darcsprefstmpdir, if it exists, otherwise by `$DARCS_TMPDIR`, and if that doesn't exist then whatever your operating system considers to be a a temporary directory (e.g. `$TMPDIR` under Unix, `$TEMP` under Windows).

If none of those exist it creates the temporary directory in the current directory, unless the current directory is under a _darcs directory, in which case the temporary directory in the parent of the highest _darcs directory to avoid accidentally corrupting darcs's internals. This should not fail, but if it does indeed fail, we go ahead and use the current directory anyway. If `$DARCS_KEEP_TMPDIR` variable is set temporary directory is not removed, this can be useful for debugging.

withPermDir :: FilePath -> (AbsolutePath -> IO a) -> IO a #

`withPermDir` is like `withTempDir`, except that it doesn't delete the directory afterwards.

withDelayedDir :: FilePath -> (AbsolutePath -> IO a) -> IO a #

withNamedTemp :: FilePath -> (FilePath -> IO a) -> IO a #

writeBinFile :: FilePathLike p => p -> ByteString -> IO () #

writeTextFile :: FilePathLike p => p -> String -> IO () #

writeDocBinFile :: FilePathLike p => p -> Doc -> IO () #

appendBinFile :: FilePathLike p => p -> ByteString -> IO () #

appendTextFile :: FilePathLike p => p -> String -> IO () #

appendDocBinFile :: FilePathLike p => p -> Doc -> IO () #

readBinFile :: FilePathLike p => p -> IO ByteString #

readTextFile :: FilePathLike p => p -> IO [String] #

readDocBinFile :: FilePathLike p => p -> IO Doc #

writeAtomicFilePS :: FilePathLike p => p -> ByteString -> IO () #

gzWriteAtomicFilePS :: FilePathLike p => p -> ByteString -> IO () #

gzWriteAtomicFilePSs :: FilePathLike p => p -> [ByteString] -> IO () #

gzWriteDocFile :: FilePathLike p => p -> Doc -> IO () #

removeFileMayNotExist :: FilePathLike p => p -> IO () #

Variant of `removeFile` that doesn't throw exception when file does not exist.

maybeRelink :: String -> String -> IO Bool #

tempdirLoc :: IO FilePath #

environmentHelpTmpdir :: ([String], [String]) #

environmentHelpKeepTmpdir :: ([String], [String]) #

addToErrorLoc :: IOException -> String -> IOException #

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

Do an action in a newly created directory of the given name. If the directory is successfully created but the action raises an exception, the directory and all its content is deleted. Caught exceptions are re-thrown.