January 2018
Beginner to intermediate
454 pages
10h 8m
English
The MKD stands for make directory (yes, exactly like the Unix command but shorter). Just like LIST and CWD, it takes PathBuf as an argument. I'll let you handle the other adds as usual and focus on the command implementation:
Command::Mkd(path) => self.mkd(path),
Just like last time, we'll create a new method:
use std::fs::create_dir;
fn mkd(&self, path: PathBuf) {
let server_root = env::current_dir().unwrap();
let path = self.cwd.join(&path);
if let Some(parent) = path.parent().map(|p| p.to_path_buf()) {
if let Ok(mut dir) = self.complete_path(parent, &server_root) {
if dir.is_dir() {
if let Some(filename) = path.file_name().map(|p| p.to_os_string()) { dir.push(filename); if create_dir(dir).is_ok() { send_cmd(&mut ...Read now
Unlock full access