Delete the folder from the sd card
Dependencies: SDFileSystem mbed
Fork of delete_file by
main.cpp
- Committer:
- jaspreetsingh
- Date:
- 2015-02-17
- Revision:
- 8:99956653b8c8
- Parent:
- 7:55590c7bed67
File content as of revision 8:99956653b8c8:
#include "mbed.h" #include "SDFileSystem.h" SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS Serial pc(USBTX, USBRX); FILE *fp; uint32_t do_list(const char *fsrc) { DIR *d = opendir(fsrc); struct dirent *p; uint32_t counter = 0; while ((p = readdir(d)) != NULL) { counter++; pc.printf("%s\n", p->d_name); } closedir(d); return counter; } 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); } int main() { pc.printf("Initializing \n"); wait(2); char dest[100]=""; pc.printf("\r\n Deleting Folder \r\n"); sprintf(dest,"/sd/NTFT/NTFT1502/NTFT150211/NTFT15021113"); // Enter the name of the folder to be deleted do_remove(dest); pc.printf("\n File Deleted \n"); }