From 358896eb7d006be28e1e79ad26f4f55d7a9901ba Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sat, 21 May 2022 14:24:43 +0300 Subject: [PATCH] nyx: tools: inform user on erros in archive bit fixer --- nyx/nyx_gui/frontend/gui_tools.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/nyx/nyx_gui/frontend/gui_tools.c b/nyx/nyx_gui/frontend/gui_tools.c index 9813313..6ca9e92 100644 --- a/nyx/nyx_gui/frontend/gui_tools.c +++ b/nyx/nyx_gui/frontend/gui_tools.c @@ -844,7 +844,10 @@ static int _fix_attributes(lv_obj_t *lb_val, char *path, u32 *total) // Hard limit path to 1024 characters. Do not result to error. if (dirLength > 1024) + { + total[2]++; goto out; + } for (;;) { @@ -875,14 +878,18 @@ static int _fix_attributes(lv_obj_t *lb_val, char *path, u32 *total) { if (!(fno.fattrib & AM_ARC)) { - total[0]++; - f_chmod(path, AM_ARC, AM_ARC); + if (!f_chmod(path, AM_ARC, AM_ARC)) + total[0]++; + else + total[3]++; } } else if (fno.fattrib & AM_ARC) // If not, clear the archive bit. { - total[1]++; - f_chmod(path, 0, AM_ARC); + if (!f_chmod(path, 0, AM_ARC)) + total[1]++; + else + total[3]++; } lv_label_set_text(lb_val, path); @@ -937,7 +944,7 @@ static lv_res_t _create_window_unset_abit_tool(lv_obj_t *btn) lv_obj_set_width(lb_val, lv_obj_get_width(val)); lv_obj_align(val, desc, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); - u32 total[2] = { 0 }; + u32 total[4] = { 0 }; _fix_attributes(lb_val, path, total); sd_unmount(); @@ -951,7 +958,15 @@ static lv_res_t _create_window_unset_abit_tool(lv_obj_t *btn) if (!total[0] && !total[1]) s_printf(txt_buf, "#96FF00 Done! No change was needed.#"); else - s_printf(txt_buf, "#96FF00 Done! Archive bits fixed:# #FF8000 %d unset, %d set!#", total[1], total[0]); + s_printf(txt_buf, "#96FF00 Done! Archive bits fixed:# #FF8000 %d unset and %d set!#", total[1], total[0]); + + // Check errors. + if (total[2] || total[3]) + { + s_printf(txt_buf, "\n\n#FFDD00 Errors: folder accesses: %d, arc bit fixes: %d!#\n" + "#FFDD00 Filesystem should be checked for errors.#", + total[2], total[3]); + } lv_label_set_text(lb_desc2, txt_buf); lv_obj_set_width(lb_desc2, lv_obj_get_width(desc2));