mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 20:47:46 +00:00
Add helper method for creating symlinks.
This commit is contained in:
parent
43d3ec7bbb
commit
c3802bb69c
1 changed files with 8 additions and 0 deletions
|
@ -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) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue