This package provides an abstraction for file and directory names and operations on them and on the corresponding file system objects.
{Path.make +S ?O}
S
, returns a corresponding
Filename
object.
{O toString($)}
{O dirname($)}
Filename
object for O
's
directory
{O basename($)}
Filename
object for O
's base
name (i.e. last component of its path).
{O toBase($)}
O
doesn't end with a slash, one
is added, and the corresponding Filename
object is
returned. This is useful for method resolve
:
D1 = {Path.make DIRECTORY}
D2 = {D1 toBase($)}
F1 = {Path.make FILENAME}
F2 = {D2 resolve(F1 $)}
{O resolve(F $)}
F
is relative, prepend O
's directory
and return the corresponding Filename
object.
{O expand($)}
O
begins with ~
or contains
.
or ..
, these are appropriately expanded and
the resulting Filename
object is returned.
{O stat($)}
OS.stat
, except that when
file O
does not exist notFound(type:unknown size:0)
is returned instead of raising an exception.
{O dirEntries($)}
Filename
objects for the files in
directory O
.
{O tree($)}
O
. This record is just like what is returned by
{O stat($)}
, except that, in the case of a directory, the
additional feature entries
is present and gives a list of
the file trees (in the same form) rooted at each of O
's
entry.
{O leaves($)}
Filename
objects for all regular
files in the file tree rooted at O
.
{O exists($)}
O
{O isDir($)}
O
exists and is a directory.
{O isFile($)}
O
exists and is a regular file.
{O size($)}
O
in bytes (0 if it doesn't
exist).
{O mkdirs}
O
exists,
else creates them. Thus, to ensure the existence of a directory
hierarchy DIR
, execute:
{{{Path.make DIR} toBase($)} mkdirs}
{O rmtree}
O
does not
appear on the file system. Thus, if O
denotes a file, the
file is deleted; if it denotes a directory, then this directory and
its contents are recursively deleted.
This package can be installed using ./ozmake --install --package=duchier-path.pkg
By default, all files of the package are
installed in the user's ~/.oz directory tree. In
particular, all modules are installed in the user's private cache.