symlink
fn symlink(string target, string link) -> Result<unit, IoError> Import
Source: use io::fs::{symlink}; compiler/src/builtin_docs/io/fs.hy Creates a symbolic link at link that points to target.
target is stored as given and need not exist. Returns
Err(IoError::AlreadyExists) when link exists. On Windows the target
must exist so the right kind of link (file or directory) can be made.
Needs --allow-write.
Parameters#
| Name | Type |
|---|---|
target | string |
link | string |
Returns#
Result<unit, IoError>
Examples#
use io::fs::{is_dir, remove_file, symlink};
use tests::assert;
let link = "/tmp/coil_doc_fs_symlink";
let _ = remove_file(link);
let made = match symlink("/tmp", link) {
Result::Ok(_) => true,
Result::Err(_) => false,
};
let points_to_dir = match is_dir(link) {
Result::Ok(b) => b,
Result::Err(_) => false,
};
let _ = remove_file(link);
assert!(made && points_to_dir);
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.