Extra-1.46.3: A grab bag of modules.

Safe HaskellNone
LanguageHaskell98

Extra.Files

Description

Some extra operations on files. The functions here generally return (Right ()) on success, Left [messages] on failure, and throw an exception when a failure leaves things in an inconsistant state. An example of an inconsistant state would be if we got a failure when writing out a file, but were unable to restore the original file to its original position.

Synopsis

Documentation

getSubDirectories :: FilePath -> IO [String] Source

Return the list of subdirectories, omitting . and .. and ignoring symbolic links.

renameAlways :: FilePath -> FilePath -> IO (Either [String] ()) Source

Change a file's name, removing any existing file with the new name.

renameMissing :: FilePath -> FilePath -> IO (Either [String] ()) Source

Change a file's name only if the new name doesn't exist.

deleteMaybe :: FilePath -> IO (Either [String] ()) Source

Delete a file if it exists

installFiles :: [(FilePath, FilePath)] -> IO (Either [String] ()) Source

Atomically install a list of files. Returns a list of what went wrong on failure. Will throw an error if it fails and is unable to restore the original files to their original states.

writeAndZipFileWithBackup :: FilePath -> ByteString -> IO (Either [String] ()) Source

Write out three versions of a file, regular, gzipped, and bzip2ed.

writeAndZipFile :: FilePath -> ByteString -> IO (Either [String] ()) Source

Write out three versions of a file, regular, gzipped, and bzip2ed. This new version assumes the files are written to temporary locations, so any existing file there can be removed.

writeFileIfMissing :: Bool -> FilePath -> String -> IO () Source

Like writeFile, but if the file already exists don't touch it. Example: writeFileIfMissing True "/var/lib/dpkg/status" ""

maybeWriteFile :: FilePath -> String -> IO () Source

Write a file if its content is different from the given text.

createSymbolicLinkIfMissing :: String -> FilePath -> IO () Source

Add-on for System.Posix.Files

forceRemoveLink :: FilePath -> IO () Source

like removeLink, but does not fail if link did not exist