Delete a file
(current_directory: &Path, args: &[&str])
| 122 | |
| 123 | /// Delete a file |
| 124 | fn rm(current_directory: &Path, args: &[&str]) { |
| 125 | if args.len() != 1 { |
| 126 | println!("Usage: rm <file>"); |
| 127 | return; |
| 128 | } |
| 129 | let file = args.first().unwrap(); |
| 130 | |
| 131 | let path = fs::canonicalize(PathBuf::from(current_directory).join(file)).unwrap(); |
| 132 | if let Err(err) = fs::remove_file(path) { |
| 133 | // Failed |
| 134 | println!("rm: cannot remove {}: {}", file, err); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | /// Make a directory |
| 139 | fn mkdir(current_directory: &Path, args: &[&str]) { |
no test coverage detected