January 2018
Beginner to intermediate
454 pages
10h 8m
English
Now that we can create folders, it'd be nice to be able to remove them, right? That's what RMD (which stands for remove directory) is supposed to do!
Just like MKD (and the others), RMD takes PathBuf as an argument. Once again, and as usual, I'll let you handle the Command part so we can focus on the command implementation:
Command::Rmd(path) => self.rmd(path),
Yep, it's a new method once again. It becomes a habit at this point I suppose?
use std::fs::remove_dir_all;
fn rmd(&self, path: PathBuf) {
let server_root = env::current_dir().unwrap();
if let Ok(path) = self.complete_path(path, &server_root) {
if remove_dir_all(path).is_ok() {
send_cmd(&mut self.stream, ResultCode::RequestedFileActionOkay, "Folder successfully ...