mirror of
https://github.com/rvtr/TDT.git
synced 2025-10-31 13:51:07 -04:00
Correctly calculate install size
It's now correct down to the byte, before you could cause the menu to error if you installed something within 16KiB or so of the limit
This commit is contained in:
parent
c8c99fa06c
commit
4ad2d28847
@ -447,10 +447,14 @@ bool install(char* fpath, bool systemTitle)
|
||||
//get install size
|
||||
iprintf("Install Size: ");
|
||||
swiWaitForVBlank();
|
||||
|
||||
|
||||
u32 clusterSize = getDsiClusterSize();
|
||||
unsigned long long fileSize = getRomSize(fpath);
|
||||
unsigned long long installSize = fileSize + _getSaveDataSize(h);
|
||||
if (tmdFound) installSize += 708;
|
||||
if ((fileSize % clusterSize) != 0)
|
||||
fileSize += clusterSize - (fileSize % clusterSize);
|
||||
//file + saves + TMD (rounded up to cluster size)
|
||||
unsigned long long installSize = fileSize + _getSaveDataSize(h) + clusterSize;
|
||||
if (tmdFound) installSize += clusterSize; //ticket, rounded up to cluster size
|
||||
|
||||
printBytes(installSize);
|
||||
iprintf("\n");
|
||||
|
||||
@ -514,10 +514,7 @@ unsigned long long getDsiSize()
|
||||
|
||||
unsigned long long getDsiFree()
|
||||
{
|
||||
u32 blockSize = 0;
|
||||
struct statvfs st;
|
||||
if (statvfs("nand:/", &st) == 0)
|
||||
blockSize = st.f_bsize;
|
||||
u32 blockSize = getDsiClusterSize();
|
||||
|
||||
//Get free space by subtracting file sizes in nand folders
|
||||
unsigned long long size = getDsiSize();
|
||||
@ -534,4 +531,13 @@ unsigned long long getDsiFree()
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
u32 getDsiClusterSize()
|
||||
{
|
||||
struct statvfs st;
|
||||
if (statvfs(sdnandMode ? "sd:/" : "nand:/", &st) == 0)
|
||||
return st.f_bsize;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ unsigned long long getSDCardFree();
|
||||
//internal storage
|
||||
unsigned long long getDsiSize();
|
||||
unsigned long long getDsiFree();
|
||||
u32 getDsiClusterSize();
|
||||
#define getDsiUsed() (getDSIStorageSize() - getDSIStorageFree())
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue
Block a user