Testbed / Mbed 2 deprecated FTPGET_Merged

Dependencies:   SDFileSystem dspmodified mbed

Revision:
3:726f275f04ac
Parent:
2:e5b9aefbcdeb
Child:
4:668d7227d060
--- a/merged_code.cpp	Mon Feb 16 11:41:18 2015 +0000
+++ b/merged_code.cpp	Tue Feb 17 07:37:15 2015 +0000
@@ -46,6 +46,7 @@
 char incoming_data[100]="";         // For FTPGET Function 
 char dest[100]="";                // For FTPGET Function   
 const char s[2] = "!";           // For FTPGET Function 
+char src[100]="";               // For FTPGET Function 
 char ftp_timestamp[100]="";     //For Timestamp.txt filename
 
 int m=0,mfinal;
@@ -346,6 +347,27 @@
     pc.printf("\r\nTimestamp.txt Storage Done\n\r");
  
  }   
+ 
+ //---------------------------------------- REMOVE THE FILE FROM THE DIRECTORY ------------------------------------------------------------------
+ 
+void do_remove(const char *fsrc)
+{
+    pc.printf("\r\n Deleting... \r\n");
+    DIR *d = opendir(fsrc);
+    struct dirent *p;
+    char path[100] = {0};
+    while((p = readdir(d)) != NULL) {
+        strcpy(path, fsrc);
+        pc.printf("\r\n path1 is %s\r\n",path);
+        strcat(path, "/");
+        pc.printf("\r\n path2 is %s\r\n",path);
+        strcat(path, p->d_name);
+        pc.printf("\r\n path3 is %s\r\n",path);
+        remove(path);
+    }
+    closedir(d);
+    remove(fsrc);
+}
 
 //--------------------------------------------------------------------------------------------------//
 //                  Storage                                                                         //
@@ -425,7 +447,7 @@
         fclose(fp);
     }
     
-    ftptimestamp();
+    ftptimestamp();    //For Timestamp.txt filename
     
     int fft_segments=4;
     int fft_start_index[4]= {0,760,1520,2280};
@@ -707,15 +729,11 @@
                      else if(atoi(token) ==4)
                      {
                          //FOR DELETING THE SELECTED FILE
-                         char removefile[100]="";
-                        pc.printf("\r\n Deleting....\r\n");
+                        char removefile[100]="";
                         token = strtok(NULL,s);
-                        sprintf(removefile,token);
-                        pc.printf("Removefile is %s\r\n",removefile);
-                        pc.printf("\r\n Deleting requested file\r\n");
-                        remove(removefile);
-                        pc.printf("\r\n File Deleted\r\n");
-                            /*
+                        sprintf(removefile,"%s",token);
+                        pc.printf("Folder to be removed is %s",removefile);
+                        
                             if(removefile==NULL)
                             {
                                 pc.printf("\r\n NULL Condition\r\n");
@@ -724,9 +742,9 @@
                             else
                             {
                                 pc.printf("\r\n Deleting requested file\r\n");
-                                remove(removefile);
+                                do_remove(removefile);
                                 pc.printf("\r\n File Deleted\r\n");
-                            }*/
+                            }
                       } 
                       /*
                       else if(atoi(token)==5)