Build the output path if it doesn't exist

... for decTitlekeys.bin / encTitlekeys.bin / seeddb.bin / aeskeydb.bin
This commit is contained in:
d0k3 2017-04-20 12:31:05 +02:00
parent f5d20aa3b5
commit c55b1b712d
3 changed files with 20 additions and 1 deletions

View File

@ -1726,6 +1726,10 @@ u32 BuildTitleKeyInfo(const char* path, bool dec, bool dump) {
if (dump) { if (dump) {
u32 dump_size = TIKDB_SIZE(tik_info); u32 dump_size = TIKDB_SIZE(tik_info);
// ensure the output dir exists
// warning: this will only build output dirs in the root dir (!!!)
if ((f_stat(OUTPUT_PATH, NULL) != FR_OK) && (f_mkdir(OUTPUT_PATH) != FR_OK))
return 1;
f_unlink(path_out); f_unlink(path_out);
if ((dump_size <= 16) || (fvx_qwrite(path_out, tik_info, 0, dump_size, &br) != FR_OK) || (br != dump_size)) if ((dump_size <= 16) || (fvx_qwrite(path_out, tik_info, 0, dump_size, &br) != FR_OK) || (br != dump_size))
return 1; return 1;
@ -1805,6 +1809,10 @@ u32 BuildSeedInfo(const char* path, bool dump) {
if (dump) { if (dump) {
u32 dump_size = SEEDDB_SIZE(seed_info); u32 dump_size = SEEDDB_SIZE(seed_info);
// ensure the output dir exists
// warning: this will only build output dirs in the root dir (!!!)
if ((f_stat(OUTPUT_PATH, NULL) != FR_OK) && (f_mkdir(OUTPUT_PATH) != FR_OK))
return 1;
f_unlink(path_out); f_unlink(path_out);
if ((dump_size <= 16) || (fvx_qwrite(path_out, seed_info, 0, dump_size, &br) != FR_OK) || (br != dump_size)) if ((dump_size <= 16) || (fvx_qwrite(path_out, seed_info, 0, dump_size, &br) != FR_OK) || (br != dump_size))
return 1; return 1;

View File

@ -17,6 +17,13 @@ u32 CryptAesKeyDb(const char* path, bool inplace, bool encrypt) {
if (!CheckWritePermissions(path_out)) if (!CheckWritePermissions(path_out))
return 1; return 1;
if (!inplace) {
// ensure the output dir exists
// warning: this will only build output dirs in the root dir (!!!)
if ((f_stat(OUTPUT_PATH, NULL) != FR_OK) && (f_mkdir(OUTPUT_PATH) != FR_OK))
return 1;
}
// load key database // load key database
if ((fvx_qread(path, keydb, 0, MAIN_BUFFER_SIZE, &bt) != FR_OK) || if ((fvx_qread(path, keydb, 0, MAIN_BUFFER_SIZE, &bt) != FR_OK) ||
(bt % sizeof(AesKeyInfo)) || (bt >= MAIN_BUFFER_SIZE)) (bt % sizeof(AesKeyInfo)) || (bt >= MAIN_BUFFER_SIZE))
@ -110,6 +117,10 @@ u32 BuildKeyDb(const char* path, bool dump) {
dump_size += sizeof(AesKeyInfo); dump_size += sizeof(AesKeyInfo);
if (dump_size >= MAX_KEYDB_SIZE) return 1; if (dump_size >= MAX_KEYDB_SIZE) return 1;
} }
// ensure the output dir exists
// warning: this will only build output dirs in the root dir (!!!)
if ((f_stat(OUTPUT_PATH, NULL) != FR_OK) && (f_mkdir(OUTPUT_PATH) != FR_OK))
return 1;
f_unlink(path_out); f_unlink(path_out);
if (!dump_size || (fvx_qwrite(path_out, key_info, 0, dump_size, &br) != FR_OK) || (br != dump_size)) if (!dump_size || (fvx_qwrite(path_out, key_info, 0, dump_size, &br) != FR_OK) || (br != dump_size))
return 1; return 1;

View File

@ -1176,7 +1176,7 @@ u32 HomeMoreMenu(char* current_path, DirStruct* current_dir, DirStruct* clipboar
DeinitSDCardFS(); DeinitSDCardFS();
if ((SdFormatMenu() == 0) || sd_state) {; if ((SdFormatMenu() == 0) || sd_state) {;
while (!InitSDCardFS() && while (!InitSDCardFS() &&
ShowPrompt(true, "Initialising SD card failed! Retry?")); ShowPrompt(true, "Initializing SD card failed! Retry?"));
} }
ClearScreenF(true, true, COLOR_STD_BG); ClearScreenF(true, true, COLOR_STD_BG);
InitEmuNandBase(true); InitEmuNandBase(true);