From b4b3148b02446cce84c0ff4ae7cb10593bade87e Mon Sep 17 00:00:00 2001 From: chaoskagami Date: Tue, 27 Dec 2016 00:10:45 -0500 Subject: [PATCH] Skip repatch of TWL / AGB unless reconfigured --- include/firm/firm.h | 2 +- source/firm/firm.c | 11 ++++++++++- source/patcher.c | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/firm/firm.h b/include/firm/firm.h index df233ae..ea32a2f 100644 --- a/include/firm/firm.h +++ b/include/firm/firm.h @@ -37,7 +37,7 @@ int prepatch_firm(const char *path, const char *prepatch_path, const char* modul /* Boots the CFW, generating caches and applying patches as-needed to the specified FIRM */ -int boot_firm(const char *firm_path, const char *prepatch_path, const char* module_path); +int boot_firm(const char* firm_path, const char* prepatch_path, const char* module_path); /* Loads a firmware off disk, returning it. The memory should be free()'d when done, unless you plan to boot. */ diff --git a/source/firm/firm.c b/source/firm/firm.c index f0b7b5b..f45d9dc 100644 --- a/source/firm/firm.c +++ b/source/firm/firm.c @@ -128,6 +128,13 @@ load_firm(const char *path, size_t *size_out) int prepatch_firm(const char* firm_path, const char* prepatch_path, const char* module_path) { + FILE* test = cropen(prepatch_path, "r"); + if (test) { + // Already exists. + crclose(test); + return 0; + } + size_t size = 0; firm_h* firm = load_firm(firm_path, &size); @@ -162,8 +169,10 @@ prepatch_firm(const char* firm_path, const char* prepatch_path, const char* modu int boot_firm(const char* firm_path, const char* prepatch_path, const char* module_path) { + firm_h* firm; + size_t size = 0; - firm_h* firm = load_firm(firm_path, &size); + firm = load_firm(firm_path, &size); if (firm == NULL) return 1; diff --git a/source/patcher.c b/source/patcher.c index a91d345..99f89b6 100644 --- a/source/patcher.c +++ b/source/patcher.c @@ -36,7 +36,8 @@ int generate_patch_cache(void) { // Remove cache - rrmdir(PATH_LOADER_CACHE); + rrmdir(PATH_TEMP); + f_mkdir(PATH_TEMP); f_mkdir(PATH_LOADER_CACHE); recurse_call(PATH_PATCHES, patch_cache_func); -- 2.39.5