From 020f4c21dfa2c372b2f5e97711eed35e82004444 Mon Sep 17 00:00:00 2001 From: mtheall Date: Mon, 24 Nov 2014 00:01:42 -0600 Subject: [PATCH] implement RMD --- source/ftp.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/source/ftp.c b/source/ftp.c index 53b6368..2693274 100644 --- a/source/ftp.c +++ b/source/ftp.c @@ -2012,12 +2012,38 @@ FTP_DECLARE(RETR) FTP_DECLARE(RMD) { - /* TODO */ +#ifdef _3DS + Result ret; +#else + int rc; +#endif + console_print("%s %s\n", __func__, args ? args : ""); ftp_session_set_state(session, COMMAND_STATE); - return ftp_send_response(session, 502, "unavailable\r\n"); + if(validate_path(args) != 0) + return ftp_send_response(session, 553, "invalid file name\r\n"); + + build_path(session, args); + +#ifdef _3DS + ret = FSUSER_DeleteDirectory(NULL, sdmcArchive, FS_makePath(PATH_CHAR, session->buffer)); + if(ret != 0) + { + console_print("FSUSER_DeleteDirectory: 0x%08X\n", (unsigned int)ret); + return ftp_send_response(session, 550, "failed to delete directory\r\n"); + } +#else + rc = rmdir(session->buffer); + if(rc != 0) + { + console_print("rmdir: %s\n", strerror(errno)); + return ftp_send_response(session, 550, "failed to delete directory\r\n"); + } +#endif + + return ftp_send_response(session, 250, "OK\r\n"); } FTP_DECLARE(RNFR)