(path: impl AsRef<Path>)
| 24 | } |
| 25 | |
| 26 | pub fn absolute_path(path: impl AsRef<Path>) -> io::Result<PathBuf> { |
| 27 | // thanks to https://stackoverflow.com/questions/30511331/getting-the-absolute-path-from-a-pathbuf |
| 28 | let path = path.as_ref(); |
| 29 | |
| 30 | let absolute_path = if path.is_absolute() { |
| 31 | path.to_path_buf() |
| 32 | } else { |
| 33 | env::current_dir()?.join(path) |
| 34 | } |
| 35 | .clean(); |
| 36 | |
| 37 | Ok(absolute_path) |
| 38 | } |
| 39 | |
| 40 | pub fn write_to_file(content: &[u8], path: &Path) -> Result<(), Box<dyn std::error::Error>> { |
| 41 | let mut file = File::create(path)?; |
no outgoing calls