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:
@@ -196,10 +196,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;
|
||||
@@ -210,6 +210,7 @@ static int _stat_and_copy_files(const char *src, const char *dst, char *path, u3
|
||||
*total_size += file_size;
|
||||
*total_files += 1;
|
||||
|
||||
// Create a copy to destination.
|
||||
if (dst)
|
||||
{
|
||||
FIL fp_src;
|
||||
|
||||
Reference in New Issue
Block a user