From 502f449904f610e1dd2d123736e7715032e118d5 Mon Sep 17 00:00:00 2001 From: its your bedtime <23366927+itsyourbedtime@users.noreply.github.com> Date: Wed, 26 May 2021 18:48:28 +0300 Subject: [PATCH] [FL-1357] CLI: SD Format confirmation #495 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- applications/sd-filesystem/sd-filesystem.c | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/applications/sd-filesystem/sd-filesystem.c b/applications/sd-filesystem/sd-filesystem.c index 2ebdadca1..29c70736b 100644 --- a/applications/sd-filesystem/sd-filesystem.c +++ b/applications/sd-filesystem/sd-filesystem.c @@ -530,17 +530,22 @@ void app_sd_eject_callback(void* context) { static void cli_sd_format(Cli* cli, string_t args, void* _ctx) { SdApp* sd_app = (SdApp*)_ctx; - printf("formatting SD card, please wait\r\n"); + printf("Formatting SD card, all data will be lost. Are you sure (y/n)?\r\n"); + char c = cli_getc(cli); + if(c == 'y' || c == 'Y') { + printf("Formatting, please wait...\r\n"); + // format card + app_sd_format_internal(sd_app); - // format card - app_sd_format_internal(sd_app); - - if(sd_app->info.status != SD_OK) { - printf("SD card format error: "); - printf(fs_error_get_internal_desc(sd_app->info.status)); - printf("\r\n"); + if(sd_app->info.status != SD_OK) { + printf("SD card format error: "); + printf(fs_error_get_internal_desc(sd_app->info.status)); + printf("\r\n"); + } else { + printf("SD card was successfully formatted.\r\n"); + } } else { - printf("SD card formatted\r\n"); + printf("Cancelled.\r\n"); } }