Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface mbed-rtos mbed
telnet_remove.cpp
00001 #include "TelnetServer.h" 00002 00003 char *header_msg_remove = "File removed successfully\r\n\r\n"; 00004 char *wrong_args_msg_remove = "Wrong number of arguments.\r\n\r\nUsage: remove <filename>\r\n"; 00005 char *file_not_found_msg_remove = "File not found.\r\n\r\n"; 00006 00007 extern LocalFileSystem local; 00008 00009 int TelnetServer::RemoveCommand(TCPSocketConnection *conn,char** argv,int argc) 00010 { 00011 00012 if(argc != 2) 00013 { 00014 conn->send(wrong_args_msg_remove,strlen(wrong_args_msg_remove)); 00015 return 0; 00016 } 00017 00018 char fullpath[256]; 00019 strcpy(fullpath,"/local/"); 00020 strcat(fullpath,argv[1]); 00021 printf("File = %s\n",fullpath); 00022 FILE* f = fopen(fullpath,"r"); 00023 if(f == NULL) 00024 { 00025 conn->send(file_not_found_msg_remove,strlen(file_not_found_msg_remove)); 00026 return 0; 00027 } 00028 00029 fclose(f); 00030 00031 local.remove(argv[1]); 00032 00033 conn->send(header_msg_remove,strlen(header_msg_remove)); 00034 00035 return 0; 00036 }
Generated on Fri Jul 22 2022 19:25:55 by
