Implementing the PWD command

This command is very simple as well. PWD stands for print working directory. Once again, it's not the one from your system but the one from your server (so again, "/" corresponds to the folder where you started the server).

The command doesn't take any argument, so there's no need to show you everything again. Let's just focus on the command handling:

Command::Pwd => {
    let msg = format!("{}", self.cwd.to_str().unwrap_or(""));
    if !msg.is_empty() {
        let message = format!("\"/{}\" ", msg);
        send_cmd(&mut self.stream, ResultCode::PATHNAMECreated,
&format!("\"/{}\" ",
msg)) } else { send_cmd(&mut self.stream, ResultCode::FileNotFound, "No
such file or directory") } }

Nothing complicated; we try to display the path, and if we fail, we return an error. The only strange thing is that if everything goes fine, we have to return PATHNAMECreated. This RFC is really strange...

Sorry, this was the last simple command. Now we'll go deeper into the FTP and its strange RFC. The following command is just a nice introduction to what's coming next. (I hope I didn't scare you!)