Fix homebrew banner padding

This commit is contained in:
Pk11 2022-01-18 22:52:02 -06:00
parent fcb97b07a5
commit baba3783f4
2 changed files with 8 additions and 8 deletions

View File

@ -487,11 +487,11 @@ bool install(char* fpath, bool systemTitle)
swiWaitForVBlank(); swiWaitForVBlank();
u32 clusterSize = getDsiClusterSize(); u32 clusterSize = getDsiClusterSize();
unsigned long long fileSize = getRomSize(fpath); unsigned long long fileSize = getRomSize(fpath), fileSizeOnDisk = fileSize;
if ((fileSize % clusterSize) != 0) if ((fileSizeOnDisk % clusterSize) != 0)
fileSize += clusterSize - (fileSize % clusterSize); fileSizeOnDisk = clusterSize - (fileSizeOnDisk % clusterSize);
//file + saves + TMD (rounded up to cluster size) //file + saves + TMD (rounded up to cluster size)
unsigned long long installSize = fileSize + _getSaveDataSize(h) + clusterSize; unsigned long long installSize = fileSizeOnDisk + _getSaveDataSize(h) + clusterSize;
if (tmdFound) installSize += clusterSize; //ticket, rounded up to cluster size if (tmdFound) installSize += clusterSize; //ticket, rounded up to cluster size
printBytes(installSize); printBytes(installSize);
@ -661,12 +661,12 @@ bool install(char* fpath, bool systemTitle)
//pad out banner if it is the last part of the file //pad out banner if it is the last part of the file
{ {
if (h->ndshdr.bannerOffset == fileSize - 0x1C00) if (h->ndshdr.bannerOffset > (fileSize - 0x23C0))
{ {
iprintf("Padding banner..."); iprintf("Padding banner...");
swiWaitForVBlank(); swiWaitForVBlank();
if (padFile(appPath, 0x7C0) == false) if (padFile(appPath, h->ndshdr.bannerOffset + 0x23C0 - fileSize) == false)
{ {
iprintf("\x1B[31m"); //red iprintf("\x1B[31m"); //red
iprintf("Failed\n"); iprintf("Failed\n");

View File

@ -186,8 +186,8 @@ bool padFile(char const* path, int size)
} }
else else
{ {
char zero = 0; for (int i = 0; i < size; i++)
fwrite(&zero, size, 1, f); fputc('\0', f);
} }
fclose(f); fclose(f);