Denys Duchier
This module provides an object-oriented interface for path and OS operations on them
The module exports not only the object-oriented API for path, but also a convenient functional API built on top of the later. It should be noted however that the functional API always needs to build path objects and thus is less efficient than the OO API, though possibly occasionally more convenient.
{Path.make +VS ?P}
VS
, returns a new path object
P
. If VS
is already a path object, then it
is simply returned.
{Path.is +X ?B}
X
is a path object
Path.'class'
{Path.toString +X ?S}
{Path.toAtom +X ?A}
{Path.length +X ?N}
{Path.isAbsolute +X ?B}
{Path.isRelative +X ?B}
{Path.dirname +X ?S}
{Path.basename +X ?S}
{Path.exists +X ?B}
{Path.stat +X ?R}
{Path.isDir +X ?B}
{Path.isFile +X ?B}
{Path.size +X ?N}
{Path.mtime +X ?N}
{Path.resolve +X1 +X2 ?S}
{Path.getcwd ?S}
{Path.mkdir +X}
{Path.mkdirs +X}
{Path.isRoot +X ?B}
{Path.readdir +X ?L}
{Path.extension +X ?S}
{Path.dropExtension +X ?S}
{Path.addExtension +X +VS ?S}
{Path.maybeAddPlatform +X ?S}
{Path.rmdir +X}
Each path object P
has the following methods:
{P init(+S windows:WIN<=ISWIN exact:EXACT<=false)}
S
. WIN
indicates that it should be considered a Windows-style path: this usually
defaults to false, except on Windows where it defaults to true.
EXACT
indicates whether we should keep a terminal slash;
the default is false.
{P initFromRecord(+R)}
{P newFromRecord(R $)}
Path
class. It's default definition is
meth newFromRecord(R $)
{New Path initFromRecord(R)}
end
{P new(+S windows:WIN<=ISWIN exact:EXACT<=false)}
S
{P toString($)}
{P toAtom($)}
{P length($)}
{P isAbsolute($)}
{P isRelative($)}
{P dirname($)}
P
{P basenameString($)}
P
{P basename($)}
P
{P exists($)}
P
exists
{P stat($)}
P
{P isDir($)}
{P isFile($)}
P
is a directory (resp. a regular file)
{P size($)}
P
in bytes
{P mtime($)}
{P resolve(+P2 $)}
P2
relative to P
(if P2
is not a path, it is made
into one)
{P getcwd($)}
{P mkdir}
P
{P mkdirs}
P
and its ancestor directories too
if necessary
{P rmdir}
P
{P isRoot($)}
P
is a root path
{P readdir($)}
P
. Entries for .
and ..
are
omitted. All other entries are resolved relative to P
{P extension($)}
P
, unit
if none
{P dropExtension($)}
P
, if any,
omitted
{P addExtension(+VS $)}
P
but with the
extension VS
added
{P maybeAddPlatform($)}
P
has extension so
then a new path
object is returned with the appropriate (for native functors) platform-specific
suffix added, else P
itself is returned
{P makeExecutable}
P
executable if this is meaningful on the current
platform