Method in path · Path coil-stdlib

Path::join

pub fn join(Path other) -> Result<Path, IoError>
Import
use path::{Path};
Source: src/path.hy

Returns this path followed by other, with exactly one separator between them.

An empty side returns the other one unchanged. other is appended even when it is absolute.

Called on a Path value as value.join(…).

Parameters#

NameType
otherPath

Returns#

Result<Path, IoError>

Examples#

use path::{Path};
use tests::assert;
let p = Path::from("logs/").join(Path::from("/today.txt")) ?? Path::from("");
assert!(p.as_str() == "logs/today.txt");
assert!((Path::from("a").join(Path::from("b")) ?? Path::from("")).as_str() == "a/b");

See also#

  • Path: A file-system path, with helpers to take it apart and to use it.
  • Path::from: Creates a path from s as written.
  • Path::as_str: Returns the path as a string.
  • Path::dirname: Returns the path without its last component.
  • Path::basename: Returns the last component, ignoring trailing separators ("" for an empty path or /).
  • Path::extension: Returns the text after the last . of the last component, or "" when there is none.
  • Path::is_absolute: Returns true when the path starts with a separator or a Windows drive letter (C:).
  • Path::normalize: Removes . components, resolves .. against the component before it, and collapses repeated separators.
↑ ↓ navigate ↵ open