4.5 Filesystem Paths
When a Rhombus operation takes a filesystem path as an argument, the path can be provided either as a string or as an instance of the path datatype. That choice is reflected by the PathString annotation. If a string is provided, it is converted to a path using the Path constructor. Beware that some paths may not be representable as strings; see Unix and Mac OS Paths and Windows Paths for more information. A Rhombus operation that generates a filesystem path always generates a path value.
By default, paths are created and manipulated for the current platform, but procedures that merely manipulate paths (without using the filesystem) can manipulate cross-platform paths using conventions for other supported platforms. The CrossPath constructor accepts a convention argument that indicates the platform for the path, either CrossPath.Convention.unix or CrossPath.Convention.windows. For other operations, such as +/, the behavior is sensitive to the kind of path that is supplied. Unless otherwise specified, an operation that requires a path accepts only paths for the current platform.
Two path values are == when they use the same convention type and when their byte-string representations are ==. A path string (or byte string) cannot be empty, and it cannot contain a null character or byte. An empty string or a string containing null does not satisfy PathString.
Most Rhombus operations that accept paths first cleanse the path before using it. Procedures that build paths or merely check the form of a path do not cleanse paths, with the exceptions of Path.cleanse, Path.simplify, filesystem.expand_user_path, and filesystem.simplify_path. For more information about path cleansing and other platform-specific details, see Unix and Mac OS Paths and Windows Paths.