- while (res == FR_OK && Finfo.fname[0]) {
- if (Finfo.fattrib & AM_DIR) {
- err(PSTR("cannot remove '%s': Is a directory"), Finfo.fname);
- } else {
- if (!(flags & N_FLAG)) {
- if ((res = f_unlink(Finfo.fname)) == FR_OK) {
- if (flags & V_FLAG)
- printf_P(PSTR("removed '%s'\n"), Finfo.fname);
+
+ if (res != FR_OK || !Finfo.fname[0]) {
+ path_fix(&from);
+ err(PSTR("cannot remove '%s%s': No such file or directory"), from.p_path, pattern);
+ } else {
+ do {
+ if (Finfo.fattrib & AM_DIR) {
+ path_fix(&from);
+ err(PSTR("cannot remove '%s%s': Is a directory"), from.p_path, Finfo.fname);
+ } else {
+ if (!(flags & N_FLAG)) {
+ if ((res = f_unlink(Finfo.fname)) == FR_OK) {
+ if (flags & V_FLAG)
+ path_fix(&from);
+ printf_P(PSTR("removed '%s%s'\n"), from.p_path, Finfo.fname);
+ path_unfix(&from);
+ } else {
+ path_fix(&from);
+ err(PSTR("cannot remove '%s%s': %S"), from.p_path, Finfo.fname, rctostr(res));
+ }