ifs 0.1.34

util for write / read file
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::{fs::remove_file, os, path::Path};

pub fn file<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> std::io::Result<()> {
  let link = link.as_ref();
  if link.exists() {
    remove_file(link)?;
  }
  #[cfg(target_os = "windows")]
  os::windows::fs::symlink_file(original, link)?;

  #[cfg(not(target_os = "windows"))]
  os::unix::fs::symlink(original, link)?;

  Ok(())
}