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
parent af0f957ddd
commit 28ebdc213e

View File

@@ -196,10 +196,10 @@ static int _stat_and_copy_files(const char *src, const char *dst, char *path, u3
// Copy file to destination disk. // Copy file to destination disk.
if (!(fno.fattrib & AM_DIR)) 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. // Check for FAT32 or total overflow.
if ((file_size + *total_size) < *total_size) if ((file_size + *total_size) > 0xFFFFFFFFu)
{ {
// Set size to > 1GB, skip next folders and return. // Set size to > 1GB, skip next folders and return.
*total_size = SZ_2G; *total_size = SZ_2G;
@@ -207,9 +207,10 @@ static int _stat_and_copy_files(const char *src, const char *dst, char *path, u3
break; break;
} }
*total_size += file_size; *total_size += file_size;
*total_files += 1; *total_files += 1;
// Create a copy to destination.
if (dst) if (dst)
{ {
FIL fp_src; FIL fp_src;