MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / rm

Function rm

shell/src/main.rs:124–136  ·  view source on GitHub ↗

Delete a file

(current_directory: &Path, args: &[&str])

Source from the content-addressed store, hash-verified

122
123/// Delete a file
124fn 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
139fn mkdir(current_directory: &Path, args: &[&str]) {

Callers 1

mainFunction · 0.85

Calls 4

canonicalizeFunction · 0.85
remove_fileFunction · 0.85
joinMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected