}
+static bool check_abort(void)
+{
+ bool ret = ctrlc();
+
+ if (ret)
+ printf_P(PSTR("Abort\n"));
+
+ return ret;
+}
+
+
static const FLASH char * const FLASH rc_names[] = {
FSTR("OK"),
FSTR("DISK_ERR"),
static
void put_rc (FRESULT rc)
{
+ if (rc < ARRAY_SIZE(rc_names)) {
#if GCC_BUG_61443
- printf_P(PSTR("rc=%u FR_"), rc);
- my_puts_P(rc_names[rc]);
- my_puts_P(PSTR("\n"));
+ printf_P(PSTR("rc=%u FR_"), rc);
+ my_puts_P(rc_names[rc]);
+ my_puts_P(PSTR("\n"));
#else
- printf_P(PSTR("rc=%u FR_%S\n"), rc, rc_names[rc]);
+ printf_P(PSTR("rc=%u FR_%S\n"), rc, rc_names[rc]);
#endif
+ }
}
/* Work register for fs command */
FILINFO Finfo;
#endif
+static const FLASH char swirlchar[] = { '-','\\','|','/' };
+
+static void swirl(void)
+{
+ static uint_fast8_t cnt;
+ static uint32_t tstamp;
+
+ if (get_timer(0) > tstamp) {
+ printf_P(PSTR("\b%c"), swirlchar[cnt]);
+ cnt = (cnt+1) % ARRAY_SIZE(swirlchar);
+ tstamp = get_timer(0) + 300;
+ }
+}
+
static
FRESULT scan_files (
char* path /* Pointer to the working buffer with start path */
char *fn;
res = f_opendir(&dirs, path);
-
+ swirl();
if (res == FR_OK) {
i = strlen(path);
while (((res = f_readdir(&dirs, &Finfo)) == FR_OK) && Finfo.fname[0]) {
AccFiles++;
AccSize += Finfo.fsize;
}
+ if (check_abort()) {
+ res = 255;
+ break;
+ }
}
}
}
#endif
if (!res) {
- my_puts_P(PSTR("\n..."));
+ my_puts_P(PSTR("\nCounting... "));
AccSize = AccFiles = AccDirs = 0;
strcpy(buffer, argv[1]);
#else
printf_P(PSTR("%s\n"), Finfo.fname);
#endif
+ if (check_abort())
+ break;
}
if (res == FR_OK) {
printf_P(PSTR("Disk full?\n"));
break;
}
- if (ctrlc()) {
- printf_P(PSTR("Abort\n"));
+ if (check_abort())
break;
- }
}
FRESULT fr = f_close(&File);