8.12
6.42 Paths
path.bytes()
is
Path.bytes(path)
path.string()
is
Path.string(path)
annotation |
Matches a path value.
Constructs a path given a byte string, string, or existing path. When a
path is provided as path, then the result is path.
> p
#<path:/home/rhombus/shape.txt>
> Path(p)
#<path:/home/rhombus/shape.txt>
> p.string()
"/home/rhombus/shape.txt"
Matches a path where the byte-string form of the path matches
bind.
> p
#"/home/rhombus/shape.txt"
Converts a path to a byte-string form, which does not lose any
information about the path.
> Path.bytes(p)
#"/home/rhombus/shape.txt"
> p.bytes()
#"/home/rhombus/shape.txt"
Converts a path to a human-readable form, but the conversion may lose
information if the path cannot be expressed using a string (e.g., due to
a byte-string form that is not a UTF-8 encoding).
> Path.string(p)
"/home/rhombus/shape.txt"
> p.string()
"/home/rhombus/shape.txt"