From 19fe7f15a96332d50f1c8c4c3682f91b12a6b874 Mon Sep 17 00:00:00 2001 From: "Such Meme, Many Skill" Date: Fri, 8 May 2020 20:57:26 +0200 Subject: [PATCH] Fix (not) asking to make sure to flash in scripts --- source/config/ini.c | 8 ++++++++ source/tegraexplorer/emmc/emmcmenu.c | 2 +- source/tegraexplorer/emmc/emmcoperations.h | 4 ++-- source/tegraexplorer/emmc/emmcrestorepart.c | 10 +++++----- source/tegraexplorer/script/functions.c | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/source/config/ini.c b/source/config/ini.c index 4c200dd..fab7ce2 100644 --- a/source/config/ini.c +++ b/source/config/ini.c @@ -73,6 +73,7 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir) char *filelist = NULL; FIL fp; ini_sec_t *csec = NULL; + bool firstIniRun = true; char *filename = (char *)malloc(256); @@ -116,10 +117,17 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir) do { + if (firstIniRun){ + firstIniRun = false; + strcpy(lbuf, "[Unknown]"); + lblen = 9; + } + else { // Fetch one line. lbuf[0] = 0; f_gets(lbuf, 512, &fp); lblen = strlen(lbuf); + } // Remove trailing newline. Depends on 'FF_USE_STRFUNC 2' that removes \r. if (lblen && lbuf[lblen - 1] == '\n') diff --git a/source/tegraexplorer/emmc/emmcmenu.c b/source/tegraexplorer/emmc/emmcmenu.c index 2fc72f1..5170f28 100644 --- a/source/tegraexplorer/emmc/emmcmenu.c +++ b/source/tegraexplorer/emmc/emmcmenu.c @@ -159,7 +159,7 @@ int makeMmcMenu(short mmcType){ case 2: if (!(clipboardhelper & ISDIR) && (clipboardhelper & OPERATIONCOPY)){ gfx_clearscreen(); - if (!mmcFlashFile(clipboard, mmcType)){ + if (!mmcFlashFile(clipboard, mmcType, true)){ gfx_printf("\nDone!"); hidWait(); } diff --git a/source/tegraexplorer/emmc/emmcoperations.h b/source/tegraexplorer/emmc/emmcoperations.h index 81d7eb1..19a6a4a 100644 --- a/source/tegraexplorer/emmc/emmcoperations.h +++ b/source/tegraexplorer/emmc/emmcoperations.h @@ -4,7 +4,7 @@ int emmcDumpSpecific(char *part, char *path); int emmcDumpBoot(char *basePath); -int mmcFlashFile(char *path, short mmcType); +int mmcFlashFile(char *path, short mmcType, bool warnings); int emmcDumpPart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part); -int emmcRestorePart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part); \ No newline at end of file +int emmcRestorePart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part, bool warnings); \ No newline at end of file diff --git a/source/tegraexplorer/emmc/emmcrestorepart.c b/source/tegraexplorer/emmc/emmcrestorepart.c index d904377..75e4ef4 100644 --- a/source/tegraexplorer/emmc/emmcrestorepart.c +++ b/source/tegraexplorer/emmc/emmcrestorepart.c @@ -17,7 +17,7 @@ extern sdmmc_storage_t storage; extern emmc_part_t *system_part; -int emmcRestorePart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part){ +int emmcRestorePart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part, bool warnings){ FIL fp; FILINFO fno; u8 *buf; @@ -54,10 +54,10 @@ int emmcRestorePart(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part){ gfx_printf("Flashing %s\n", part->name); - if (totalSize < totalSizeDest){ + if (totalSize < totalSizeDest && warnings){ SWAPCOLOR(COLOR_ORANGE); gfx_printf("File is too small for destination.\nDo you want to flash it anyway?\n\nB to Cancel\n"); - u8 btnres = gfx_makewaitmenu( + u32 btnres = gfx_makewaitmenu( "A to Confirm", 3 ); @@ -214,13 +214,13 @@ emmc_part_t *mmcFindPart(char *path, short mmcType){ return NULL; } -int mmcFlashFile(char *path, short mmcType){ +int mmcFlashFile(char *path, short mmcType, bool warnings){ emmc_part_t *part; int res; part = mmcFindPart(path, mmcType); if (part != NULL){ - res = emmcRestorePart(path, &storage, part); + res = emmcRestorePart(path, &storage, part, warnings); emummc_storage_set_mmc_partition(&storage, 0); return res; } diff --git a/source/tegraexplorer/script/functions.c b/source/tegraexplorer/script/functions.c index c1cf232..b9a4c1f 100644 --- a/source/tegraexplorer/script/functions.c +++ b/source/tegraexplorer/script/functions.c @@ -524,7 +524,7 @@ int part_mmc_restorePart(){ if (currentlyMounted < 0) return -1; - return mmcFlashFile(path, currentlyMounted); + return mmcFlashFile(path, currentlyMounted, false); } int part_fs_extractBisFile(){