darcs-2.18.3: a distributed, interactive, smart revision control system
Safe HaskellSafe-Inferred
LanguageHaskell2010

Darcs.Util.File

Synopsis

Files and directories

getFileStatus :: FilePath -> IO (Maybe FileStatus) Source #

Badly named, since it is actually getSymbolicLinkStatus, with all IOErrors turned into Nothing.

doesDirectoryReallyExist :: FilePath -> IO Bool Source #

Whether a path is an existing directory, but not a symlink to one.

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

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

getRecursiveContents :: FilePath -> IO [FilePath] Source #

Return all files under given directory that aren't directories.

getRecursiveContentsFullPath :: FilePath -> IO [FilePath] Source #

Return all files under given directory that aren't directories. Unlike getRecursiveContents this function returns the full path.

copyTree :: FilePath -> FilePath -> IO () Source #

Recursively copy a directory, where the target directory is supposed to already exist.

Fetching files

fetchFilePS :: String -> Cachable -> IO ByteString Source #

fetchFilePS fileOrUrl cache returns the content of its argument (either a file or an URL). If it has to download an url, then it will use a cache as required by its second argument.

We always use default remote darcs, since it is not fatal if the remote darcs does not exist or is too old -- anything that supports transfer-mode should do, and if not, we will fall back to SFTP or SCP.

fetchFileLazyPS :: String -> Cachable -> IO ByteString Source #

fetchFileLazyPS fileOrUrl cache lazily reads the content of its argument (either a file or an URL). Warning: this function may constitute a fd leak; make sure to force consumption of file contents to avoid that. See "fetchFilePS" for details.

gzFetchFilePS :: String -> Cachable -> IO ByteString Source #

Like fetchFilePS but transparently handle gzip compressed files.

speculateFileOrUrl :: String -> FilePath -> IO () Source #

Initiate background file download for the given file path or URL to the given location.

copyFileOrUrl Source #

Arguments

:: String

remote darcs executable

-> String

path representing the origin file or URL

-> FilePath

destination path

-> Cachable

tell whether file to copy is cachable

-> IO () 

Very much darcs-specific copying procedure. For local files it tries to hard-link, falling back to normal copy if it fails. Remote URLs are downloaded using either HTTP or SSH. For SSH, this tries to use the given remote darcs command to invoke it's transfer-mode command.

data Cachable Source #

Constructors

Cachable 
Uncachable 
MaxAge !CInt 

Instances

Instances details
Show Cachable Source # 
Instance details

Defined in Darcs.Util.HTTP

Eq Cachable Source # 
Instance details

Defined in Darcs.Util.HTTP

Backup

Temporary files

withTemp :: (FilePath -> IO a) -> IO a Source #

Invoke the given action on a file that is temporarily created in the current directory, and removed afterwards.

withOpenTemp :: ((Handle, FilePath) -> IO a) -> IO a Source #

Invoke the given action on a file that is temporarily created and opened in the current directory, and closed and removed afterwards.