forked from Mirror/GodMode9
Simplified TAR code
This commit is contained in:
parent
20d2772056
commit
45b7a75af0
@ -123,7 +123,7 @@ u32 LoadKeyDb(const char* path_db, AesKeyInfo* keydb, u32 bsize) {
|
||||
} else {
|
||||
// check for hardcoded key database
|
||||
u64 aeskeydb_bin_size = 0;
|
||||
void* aeskeydb_bin = FindVTarFileInfo(VRAM0_AESKEY_DB, &aeskeydb_bin_size, NULL);
|
||||
void* aeskeydb_bin = FindVTarFileInfo(VRAM0_AESKEY_DB, &aeskeydb_bin_size);
|
||||
fsize = (aeskeydb_bin_size <= bsize) ? aeskeydb_bin_size : 0;
|
||||
if (fsize) memcpy(keydb, aeskeydb_bin, aeskeydb_bin_size);
|
||||
|
||||
|
@ -1589,7 +1589,7 @@ u32 HomeMoreMenu(char* current_path) {
|
||||
int hsrestore = ((CheckHealthAndSafetyInject("1:") == 0) || (CheckHealthAndSafetyInject("4:") == 0)) ? (int) ++n_opt : -1;
|
||||
int clock = ++n_opt;
|
||||
int sysinfo = ++n_opt;
|
||||
int readme = (FindVTarFileInfo(VRAM0_README_MD, NULL, NULL)) ? (int) ++n_opt : -1;
|
||||
int readme = (FindVTarFileInfo(VRAM0_README_MD, NULL)) ? (int) ++n_opt : -1;
|
||||
|
||||
if (sdformat > 0) optionstr[sdformat - 1] = "SD format menu";
|
||||
if (bonus > 0) optionstr[bonus - 1] = "Bonus drive setup";
|
||||
@ -1704,7 +1704,7 @@ u32 HomeMoreMenu(char* current_path) {
|
||||
}
|
||||
else if (user_select == readme) { // Display GodMode9 readme
|
||||
u64 README_md_size;
|
||||
char* README_md = FindVTarFileInfo(VRAM0_README_MD, &README_md_size, NULL);
|
||||
char* README_md = FindVTarFileInfo(VRAM0_README_MD, &README_md_size);
|
||||
MemToCViewer(README_md, README_md_size, "GodMode9 ReadMe Table of Contents");
|
||||
return 0;
|
||||
} else return 1;
|
||||
@ -1713,7 +1713,7 @@ u32 HomeMoreMenu(char* current_path) {
|
||||
}
|
||||
|
||||
u32 SplashInit(const char* modestr) {
|
||||
void* splash = FindVTarFileInfo(VRAM0_SPLASH_QLZ, NULL, NULL);
|
||||
void* splash = FindVTarFileInfo(VRAM0_SPLASH_QLZ, NULL);
|
||||
const char* namestr = FLAVOR " " VERSION;
|
||||
const char* loadstr = "booting...";
|
||||
const u32 pos_xb = 10;
|
||||
@ -1723,7 +1723,7 @@ u32 SplashInit(const char* modestr) {
|
||||
|
||||
ClearScreenF(true, true, COLOR_STD_BG);
|
||||
if (splash) QlzDecompress(TOP_SCREEN, splash, 0);
|
||||
else DrawStringF(TOP_SCREEN, 10, 10, COLOR_STD_FONT, COLOR_TRANSPARENT, "(splash not found)");
|
||||
else DrawStringF(TOP_SCREEN, 10, 10, COLOR_STD_FONT, COLOR_TRANSPARENT, "(" VRAM0_SPLASH_QLZ " not found)");
|
||||
if (modestr) DrawStringF(TOP_SCREEN, SCREEN_WIDTH_TOP - 10 - GetDrawStringWidth(modestr),
|
||||
SCREEN_HEIGHT - 10 - GetDrawStringHeight(modestr), COLOR_STD_FONT, COLOR_TRANSPARENT, modestr);
|
||||
|
||||
@ -2309,7 +2309,7 @@ u32 ScriptRunner(int entrypoint) {
|
||||
|
||||
// get script from VRAM0 TAR
|
||||
u64 autorun_gm9_size = 0;
|
||||
void* autorun_gm9 = FindVTarFileInfo(VRAM0_AUTORUN_GM9, &autorun_gm9_size, NULL);
|
||||
void* autorun_gm9 = FindVTarFileInfo(VRAM0_AUTORUN_GM9, &autorun_gm9_size);
|
||||
|
||||
if (autorun_gm9 && autorun_gm9_size) {
|
||||
// copy script to script buffer and run it
|
||||
|
@ -32,7 +32,7 @@ u32 ValidateTarHeader(void* tardata, void* tardata_end) {
|
||||
return 1;
|
||||
|
||||
// type can only be standard file or dir
|
||||
if ((tar->ftype != '0') && (tar->ftype != '5'))
|
||||
if (tar->ftype && (tar->ftype != '0') && (tar->ftype != '5'))
|
||||
return 1;
|
||||
|
||||
// checksum
|
||||
@ -70,13 +70,13 @@ void* NextTarEntry(void* tardata, void* tardata_end) {
|
||||
return data;
|
||||
}
|
||||
|
||||
void* FindTarFileInfo(void* tardata, void* tardata_end, const char* fname, u64* fsize, bool* is_dir) {
|
||||
void* FindTarFileInfo(void* tardata, void* tardata_end, const char* fname, u64* fsize) {
|
||||
while (tardata && (tardata < tardata_end)) {
|
||||
TarHeader* tar = tardata;
|
||||
|
||||
if (ValidateTarHeader(tardata, tardata_end) != 0) break;
|
||||
if ((strncasecmp(tar->fname, fname, 100) == 0) && (tar->ftype == '0'))
|
||||
return GetTarFileInfo(tardata, NULL, fsize, is_dir);
|
||||
if ((strncasecmp(tar->fname, fname, 100) == 0) && (!tar->ftype || (tar->ftype == '0')))
|
||||
return GetTarFileInfo(tardata, NULL, fsize, NULL);
|
||||
tardata = ((u8*) tardata) + sizeof(TarHeader) + align(ReadAsciiOctal(tar->fsize, 12), 512);
|
||||
}
|
||||
|
||||
|
@ -32,4 +32,4 @@ typedef struct {
|
||||
u32 ValidateTarHeader(void* tardata, void* tardata_end);
|
||||
void* GetTarFileInfo(void* tardata, char* fname, u64* fsize, bool* is_dir);
|
||||
void* NextTarEntry(void* tardata, void* tardata_end);
|
||||
void* FindTarFileInfo(void* tardata, void* tardata_end, const char* fname, u64* fsize, bool* is_dir);
|
||||
void* FindTarFileInfo(void* tardata, void* tardata_end, const char* fname, u64* fsize);
|
||||
|
@ -34,5 +34,5 @@
|
||||
#define GetVTarFileInfo(tardata, fname, fsize, is_dir) \
|
||||
GetTarFileInfo(tardata, fname, fsize, is_dir)
|
||||
|
||||
#define FindVTarFileInfo(fname, fsize, is_dir) \
|
||||
FindTarFileInfo(TARDATA, TARDATA_END, fname, fsize, is_dir)
|
||||
#define FindVTarFileInfo(fname, fsize) \
|
||||
FindTarFileInfo(TARDATA, TARDATA_END, fname, fsize)
|
||||
|
Loading…
x
Reference in New Issue
Block a user