Function in io::fs compiler

realpath

fn realpath(string path) -> Result<string, IoError>
Import
use io::fs::{realpath};
Source: compiler/src/builtin_docs/io/fs.hy

Returns the canonical absolute form of path, with every symbolic link, . and .. resolved.

The path must exist; otherwise returns Err(IoError::NotFound). Needs --allow-read.

Parameters#

NameType
pathstring

Returns#

Result<string, IoError>

Examples#

use io::fs::{create_dir_all, realpath, remove_dir_all};
use tests::assert;
let _ = create_dir_all("/tmp/coil_doc_fs_realpath/sub");
let p = match realpath("/tmp/coil_doc_fs_realpath/sub/..") {
    Result::Ok(p) => p,
    Result::Err(_) => "",
};
let q = match realpath("/tmp/coil_doc_fs_realpath") {
    Result::Ok(p) => p,
    Result::Err(_) => "?",
};
let _ = remove_dir_all("/tmp/coil_doc_fs_realpath");
assert!(p == q);

See also#

  • copy: Copies the contents of file from to to, creating or overwriting to.
  • create_dir: Creates the directory path.
  • create_dir_all: Creates the directory path and any missing parent directories.
  • exists: Returns whether anything exists at path.
  • is_dir: Returns whether path is a directory, following symbolic links.
  • is_file: Returns whether path is a regular file, following symbolic links.
  • is_symlink: Returns whether path itself is a symbolic link (the link is not followed).
  • list_dir: Returns the names of the entries in directory path, sorted.
↑ ↓ navigate ↵ open