read_link
fn read_link(string path) -> Result<string, IoError> Import
Source: use io::fs::{read_link}; compiler/src/builtin_docs/io/fs.hy Returns the target stored in the symbolic link at path.
The target is returned as written when the link was made (it may be
relative and need not exist). Returns Err(IoError::InvalidInput) (or
another error, depending on the OS) when path is not a link.
Needs --allow-read.
Parameters#
| Name | Type |
|---|---|
path | string |
Returns#
Result<string, IoError>
Examples#
use io::fs::{read_link, remove_file, symlink};
use tests::assert;
let link = "/tmp/coil_doc_fs_read_link";
let _ = remove_file(link);
let _ = symlink("some/target.txt", link);
let target = match read_link(link) {
Result::Ok(t) => t,
Result::Err(_) => "",
};
let _ = remove_file(link);
assert!(target == "some/target.txt");
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.