Path package:MissingH

This module provides various helpful utilities for dealing with path and file names, directories, and related support. Written by John Goerzen, jgoerzen@complete.org
File and directory names are values of type String, whose precise meaning is operating system dependent. Files can be opened, yielding a handle which can then be used to operate on the contents of that file.
Gets a full path, after investigating the cwd.
Make an absolute, normalized version of a path with all double slashes, dot, and dotdot entries removed. The first parameter is the base for the absolut calculation; in many cases, it would correspond to the current working directory. The second parameter is the pathname to transform. If it is already absolute, the first parameter is ignored. Nothing may be returned if there's an error; for instance, too many .. entries for the given path.
Like absNormPath, but returns Nothing if the generated result is not the passed base path or a subdirectory thereof.
Make a path absolute, using the current working directory. This makes a relative path absolute with respect to the current working directory. An absolute path is returned unmodified. The current working directory is determined with getCurrentDirectory which means that symbolic links in it are expanded and the path is normalised. This is different from pwd.
Make a path absolute. This makes a relative path absolute with respect to a specified directory. An absolute path is returned unmodified. The order of the arguments can be confusing. You should rather use absolute_path_by. absolute_path' is included for backwards compatibility.
Make a path absolute. This makes a relative path absolute with respect to a specified directory. An absolute path is returned unmodified.
Normalise a path. This is done by reducing repeated / characters to one, and removing . path components. .. path components are left intact, because of possible symlinks.
normalise_path = unslice_path . slice_path
Split a path in components. Repeated "/" characters don't lead to empty components. "." path components are removed. If the path is absolute, the first component will start with "/". ".." components are left intact. They can't be simply removed, because the preceding component might be a symlink. In this case, realpath is probably what you need. The case that the path is empty, is probably an error. However, it is treated like ".", yielding an empty path components list. Examples:
slice_path "/"        = ["/"]
slice_path "/foo/bar" = ["/foo","bar"]
slice_path "..//./"   = [".."]
slice_path "."        = []
See unslice_path, realpath, realpath_s.
Split a path in directory and file name. Only in the case that the supplied path is empty, both parts are empty strings. Otherwise, "." is filled in for the corresponding part, if necessary. Unless the path is empty, concatenating the returned path and file name components with a slash in between, makes a valid path to the file. split_path splits off the last path component. This isn't the same as the text after the last /. Note that the last path component might be "..". Then it is not possible to deduce the refered directory's name from the path. Then an IO action for getting the real path is necessary. Examples:
split_path "/a/b/c"      == ("/a/b", "c")
split_path "foo"         == (".", "foo")
split_path "foo/bar"     == ("foo", "bar")
split_path "foo/.."      == ("foo", "..")
split_path "."           == (".", ".")
split_path ""            == ("", "")
split_path "/foo"        == ("/", "foo")
split_path "foo/"        == (".", "foo")
split_path "foo/."       == (".", "foo")
split_path "foo///./bar" == ("foo", "bar")
See slice_path.
Form a path from path components. This isn't the inverse of slice_path, since unslice_path . slice_path normalises the path. See slice_path.
Inverse of split_path, except for normalisation. This concatenates two paths, and takes care of "." and empty paths. When the two components are the result of split_path, then unsplit_path creates a normalised path. It is best documented by its definition:
unsplit_path (".", "") = "."
unsplit_path ("", ".") = "."
unsplit_path (".", q)  = q
unsplit_path ("", q)   = q
unsplit_path (p, "")   = p
unsplit_path (p, ".")  = p
unsplit_path (p, q)    = p ++ "/" ++ q
Examples:
unsplit_path ("", "")     == ""
unsplit_path (".", "")    == "."
unsplit_path (".", ".")   == "."
unsplit_path ("foo", ".") == "foo"
See split_path.