Skip to content

Commit 2e51b31

Browse files
yackushevasmattnenterprise
authored andcommitted
add DELE command for delete file. (#46)
1 parent e7b883d commit 2e51b31

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/ftp.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl FtpStream {
8282
};
8383
self.secure_with_ssl(ssl)
8484
}
85-
85+
8686
/// Switch to a secure mode if possible, using a provided SSL configuration.
8787
/// This method does nothing if the connect is already secured.
8888
///
@@ -447,6 +447,14 @@ impl FtpStream {
447447
Ok(())
448448
}
449449

450+
/// Remove the remote file from the server.
451+
pub fn rm(&mut self, filename: &str) -> Result<()> {
452+
let rm_command = format!("DELE {}\r\n", filename);
453+
try!(self.write_str(&rm_command));
454+
try!(self.read_response(status::REQUESTED_FILE_ACTION_OK));
455+
Ok(())
456+
}
457+
450458
fn put_file<R: Read>(&mut self, filename: &str, r: &mut R) -> Result<()> {
451459
let stor_command = format!("STOR {}\r\n", filename);
452460
let mut data_stream = BufWriter::new(try!(self.data_command(&stor_command)));

0 commit comments

Comments
 (0)