realpath
fn realpath(string path) -> Result<string, IoError> Import
Source: use io::fs::{realpath}; 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#
| Name | Type |
|---|---|
path | string |
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 filefromtoto, creating or overwritingto.create_dir: Creates the directorypath.create_dir_all: Creates the directorypathand any missing parent directories.exists: Returns whether anything exists atpath.is_dir: Returns whetherpathis a directory, following symbolic links.is_file: Returns whetherpathis a regular file, following symbolic links.is_symlink: Returns whetherpathitself is a symbolic link (the link is not followed).list_dir: Returns the names of the entries in directorypath, sorted.