diff --git a/arm9/src/install.c b/arm9/src/install.c index 4772296..67b2ab9 100644 --- a/arm9/src/install.c +++ b/arm9/src/install.c @@ -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"); diff --git a/arm9/src/storage.c b/arm9/src/storage.c index 4fdd564..74ebbf3 100644 --- a/arm9/src/storage.c +++ b/arm9/src/storage.c @@ -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; -} \ No newline at end of file +} + +u32 getDsiClusterSize() +{ + struct statvfs st; + if (statvfs(sdnandMode ? "sd:/" : "nand:/", &st) == 0) + return st.f_bsize; + + return 0; +} diff --git a/arm9/src/storage.h b/arm9/src/storage.h index 8701cf6..811d6a8 100644 --- a/arm9/src/storage.h +++ b/arm9/src/storage.h @@ -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 \ No newline at end of file