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();
u32 clusterSize = getDsiClusterSize();
unsigned long long fileSize = getRomSize(fpath);
if ((fileSize % clusterSize) != 0)
fileSize += clusterSize - (fileSize % clusterSize);
unsigned long long fileSize = getRomSize(fpath), fileSizeOnDisk = fileSize;
if ((fileSizeOnDisk % clusterSize) != 0)
fileSizeOnDisk = clusterSize - (fileSizeOnDisk % clusterSize);
//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
printBytes(installSize);
@ -661,12 +661,12 @@ bool install(char* fpath, bool systemTitle)
//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...");
swiWaitForVBlank();
if (padFile(appPath, 0x7C0) == false)
if (padFile(appPath, h->ndshdr.bannerOffset + 0x23C0 - fileSize) == false)
{
iprintf("\x1B[31m"); //red
iprintf("Failed\n");

View File

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