nyx: handle exFAT truncation in stat/backup

It's possible for the overflow check to fail if exFAT and file size is big enough.
(4GB + total_size)

So check it properly.
This avoids unnecessary copying before RAM disk gets filled and copy errors out.

No other check is needed since max capacity is RAM disk size.
This commit is contained in:
CTCaer
2026-01-18 21:01:54 +02:00
committed by NaGa
parent 16b14b74c2
commit ef84b9804c

View File

@@ -279,10 +279,10 @@ static int _stat_and_copy_files(const char *src, const char *dst, char *path, u3
// Copy file to destination disk.
if (!(fno.fattrib & AM_DIR))
{
u32 file_size = fno.fsize > RAMDISK_CLUSTER_SZ ? fno.fsize : RAMDISK_CLUSTER_SZ; // Ramdisk cluster size.
u64 file_size = fno.fsize > RAMDISK_CLUSTER_SZ ? fno.fsize : RAMDISK_CLUSTER_SZ;
// Check for overflow.
if ((file_size + *total_size) < *total_size)
// Check for FAT32 or total overflow.
if ((file_size + *total_size) > 0xFFFFFFFFu)
{
// Set size to > 1GB, skip next folders and return.
*total_size = SZ_2G;
@@ -290,9 +290,10 @@ static int _stat_and_copy_files(const char *src, const char *dst, char *path, u3
break;
}
*total_size += file_size;
*total_size += file_size;
*total_files += 1;
// Create a copy to destination.
if (dst)
{
FIL fp_src;