On this page:
Cross  Path.Convention
Cross  Path.Convention.unix
Cross  Path.Convention.windows
Cross  Path
Cross  Path.Absolute
Cross  Path.Relative
Cross  Path.Drive  Relative
Cross  Path.Directory
Cross  Path.Element
Cross  Path.Unix
Cross  Path.Windows
Cross  Path
Cross  Path.Unix
Cross  Path.Windows
Cross  Path
Cross  Path.Convention.current
8.15.0.12

14.2 Cross-Platform Paths🔗ℹ

A cross-platform path value represents a filesystem path combined with #'unix or #'windows to indicate the filesystem’s path convention. A cross-platform path whose convention matches the current host system is also a path. The . operator can be used on a cross-platform path expression in the same way as path expressions.

Cross-platform paths are comparable the same as paths, which means that generic operations like < and > work on paths, cross-platform paths, and combinations. Paths with the #'unix convention are ordered before paths with the #'windows convention.

enumeration

enum CrossPath.Convention:

  unix

  windows

 

annotation

CrossPath

 

annotation

CrossPath.Absolute

 

annotation

CrossPath.Relative

 

annotation

CrossPath.DriveRelative

 

annotation

CrossPath.Directory

 

annotation

CrossPath.Element

 

annotation

CrossPath.Unix

 

annotation

CrossPath.Windows

The CrossPath.Convention enumeration represents the two supported path conventions. Other annotations are analogous to Path, Path.Absolute, Path.Relative, Path.DriveRelative, Path.Directory, Path.Element. The CrossPath.Unix and CrossPath.Windows annotations are satisfied by cross-platform paths with those respective conventions.

Every Path is also a CrossPath, and Path.convention for a Path will produce the same symbol as CrossPath.Convention.current(). Operations on CrossPaths also work on Path, but they typically do not accept strings, instead requiring Path or CrossPath values that have an associated convention.

function

fun CrossPath(

  cross_path :: Bytes || Path.Dot || CrossPath,

  convention :: CrossPath.Convention = CrossPath.Convention.current()

) :: CrossPath

 

function

fun CrossPath.Unix(cross_path :: Bytes || Path.Dot) :: CrossPath

 

function

fun CrossPath.Windows(cross_path :: Bytes || Path.Dot) :: CrossPath

The CrossPath function constructs a cross-platform path given a byte string and path convention. When a cross-platform path is provided as cross_path, then the result is cross_path.

The CrossPath.Unix and CrossPath.Windows functions are shorthands for CrossPath with #'unix and #'windows, respectively.

> def p = CrossPath(#"/home/rhombus/shape.txt", #'unix)

> p.string()

"/home/rhombus/shape.txt"

> p.convention()

#'unix

Matches a cross-platform path where the byte-string form of the path matches bytes_bind and the convention matches convention_bind.

> def CrossPath(bstr, _) = Path("/home/rhombus/shape.txt")

> bstr

#"/home/rhombus/shape.txt"

Reports the convention of the current platform, either #'unix or #'windows.