Skip to content

Commit c3858a7

Browse files
committed
Add DEL * / RM * to resolve #211
1 parent 2da1dc8 commit c3858a7

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

Firmware/OpenLog_Artemis/zmodem.ino

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff 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\nDeleting ")); 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\nFiles deleted!\r\n"));
331+
}
332+
else
333+
{
334+
DSERIALprintln(F("\r\nNo files to delete\r\n"));
335+
}
336+
337+
root.close();
338+
}
339+
else if (!sd.remove(param))
304340
{
305341
DSERIALprint(F("\r\nFailed to delete file "));
306342
DSERIAL->flush(); DSERIAL->println(param); DSERIAL->flush();

0 commit comments

Comments
 (0)