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)