std-function
Unix symlink: create a symbolic link
Unix only. A symbolic link stores a target pathname; a relative target is resolved from the directory containing the link. Windows uses different APIs and permissions. Use a fresh disposable working directory exclusively controlled by this program. Expected stdout (not executed): ok Common mistake: Resolving a relative link target from the process working directory.
Formal Syntax & Structure
rust syntaxrust
std::os::unix::fs::symlink(target, link) -> io::Result<()>Working Example
Example Snippetrust
fn main() { use std::fs::{self, File}; use std::io::{Read, Write}; fs::create_dir("bm-fixture").expect("fresh working directory required"); let p = std::path::Path::new("bm-fixture").join("note.txt"); File::create_new(&p).unwrap().write_all(b"ok").unwrap(); let q = p.with_file_name("alias"); std::os::unix::fs::symlink("note.txt", &q).unwrap(); println!("{}", fs::read_to_string(q).unwrap());}