1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 13:07:46 +00:00

Add helper method for creating symlinks.

This commit is contained in:
Joseph Crail 2015-06-04 00:03:25 -04:00
parent 43d3ec7bbb
commit c3802bb69c

View file

@ -2,6 +2,10 @@
use std::fs::{self, File}; use std::fs::{self, File};
use std::io::{Read, Write}; use std::io::{Read, Write};
#[cfg(unix)]
use std::os::unix::fs::symlink as symlink_file;
#[cfg(windows)]
use std::os::windows::fs::symlink_file;
use std::path::Path; use std::path::Path;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use std::str::from_utf8; use std::str::from_utf8;
@ -74,6 +78,10 @@ pub fn touch(file: &str) {
File::create(Path::new(file)).unwrap(); File::create(Path::new(file)).unwrap();
} }
pub fn symlink(src: &str, dst: &str) {
symlink_file(src, dst).unwrap();
}
pub fn cleanup(path: &'static str) { pub fn cleanup(path: &'static str) {
let p = Path::new(path); let p = Path::new(path);
match fs::metadata(p) { match fs::metadata(p) {