File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -300,7 +300,43 @@ void sdCardMenu(int numberOfSeconds)
300300
301301 else if (!strcmp_P (cmd, PSTR (" DEL" )) || !strcmp_P (cmd, PSTR (" RM" ))) // ReMove / DELete file
302302 {
303- if (!sd.remove (param))
303+ if (!strcmp_P (param, PSTR (" *" )))
304+ {
305+
306+ count_files (&Filesleft, &Totalleft);
307+ DSERIALprint (F (" \r\n Deleting " )); DSERIAL->print (Filesleft); DSERIALprint (F (" files (" )); DSERIAL->print (Totalleft); DSERIALprintln (F (" bytes)" ));
308+
309+ root.open (" /" ); // (re)open the root directory
310+ root.rewind (); // rewind
311+
312+ if (Filesleft > 0 )
313+ {
314+ // while (sd.vwd()->readDir(dir) == sizeof(*dir)) {
315+ while (fout.openNext (&root, O_RDONLY))
316+ {
317+ // read next directory entry in current working directory
318+ if (!fout.isDir ()) {
319+ char fname[30 ];
320+ size_t fsize = 30 ;
321+ fout.getName (fname, fsize);
322+ fout.close ();
323+ sd.remove (fname);
324+ }
325+ else
326+ {
327+ fout.close ();
328+ }
329+ }
330+ DSERIALprintln (F (" \r\n Files deleted!\r\n " ));
331+ }
332+ else
333+ {
334+ DSERIALprintln (F (" \r\n No files to delete\r\n " ));
335+ }
336+
337+ root.close ();
338+ }
339+ else if (!sd.remove (param))
304340 {
305341 DSERIALprint (F (" \r\n Failed to delete file " ));
306342 DSERIAL->flush (); DSERIAL->println (param); DSERIAL->flush ();
You can’t perform that action at this time.
0 commit comments