backstop-1.3.0.354: Backstop a target directory by source directories

Safe HaskellSafe
LanguageHaskell2010

Utils

Synopsis

Documentation

pairs :: [a] -> [(a, a)] Source #

Given a list [a], pairs returns the list of all pairs [(a,a)] of [a] progressing from the head to tail of [a]. For example,

pairs [x1,x2,x3,x4]
== [(x1,x2),(x1,x3),(x1,x4),(x2,x3),(x2,x4),(x3,x4)]

Note that

pairs []     == []
pairs (x:[]) == []

unpairs :: Eq a => [(a, a)] -> [a] Source #

For length l /= 1,

(unpairs . pairs) l == l

is True.

Number of elements    Number of pairs
------------------    ---------------
                 0 => 0
                 1 => 0
                 2 => 1
                 3 => 3
                 4 => 6
                 5 => 10
                 e => p = e(e-1)/2, e >= 0

root :: FilePath Source #

root = [pathSeparator]

reduceFilePath :: FilePath -> FilePath Source #

reduceFilePath returns a pathname that is reduced to canonical form equivalent to that of ksh(1), that is, symbolic link names are treated literally when finding the directory name. See cd -L of ksh(1). Specifically, extraneous separators ("/"), dot ("."), and double-dot ("..") directories are removed.

absoluteLink :: FilePath -> FilePath -> FilePath -> FilePath Source #

Given a pathname wd representing a workng directory and two pathnames p1 and p2, absoluteLink returns the reduced (reduceFilePath) and absolute path to p2 to which p1 could point as a symbolic link.

If wd is not an absolute path, it is assumed to be a relative path that is relative to the root directory of the file system tree and is made an absolute path.

relativeLink :: FilePath -> FilePath -> FilePath -> FilePath Source #

Given a pathname wd representing a workng directory and two pathnames p1 and p2, relativeLink returns the reduced (reduceFilePath) and relative path from p1 to p2 to which p1 could point as a symbolic link. Thus, p1 must not be the root ("/"), dot ("."), nor double-dot ("..") directories but of the form "/SomePath/SymLink"

If wd is not an absolute path, it is assumed to be a relative path that is relative to the root directory of the file system tree and is made an absolute path.

compElems :: Eq a => [a] -> [a] -> ([a], [a], [a]) Source #

compElems compares elements of two lists and returns the list of elements that are in both lists, unique to the first list, and uniqued to the second list. Duplicates are nubed.

subdirectories :: FilePath -> FilePath -> Bool Source #

subdirectories returns true if either the absolute pathname p1 or the absolute pathname p2 is a sub-directory or sub-path of the other.

subdirectory :: FilePath -> FilePath -> Bool Source #

subdirectory returns true if the absolute pathname p1 is a subdirectory of the absolute pathname p2 as in

p1 `subdirectory` p2

otherwise false.

aDirectory :: FilePath -> IO Bool Source #

aDirectory returns true if p is not a symbolic link and is a directory, otherwise false.

aSymbolicLink :: FilePath -> IO Bool Source #

aSymbolicLink returns true if p is a symbolic link, otherwise false.

anObject :: FilePath -> IO Bool Source #

anObject returns true if p is an object in the filesystem, otherwise false. Symbolic links are not deferenced.

putOrPageStrLn :: String -> IO ExitCode Source #

Put a string or page it if the environmental variable PAGER is set.