add some error handling for ridiculous mis-uses of cflash directories containing too many GB of files
This commit is contained in:
parent
4ffac4d2df
commit
b50a86f560
|
@ -309,7 +309,7 @@ static void list_files(const char *filepath, ListCallback list_callback)
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 dataSectors = 0;
|
static u64 dataSectors = 0;
|
||||||
void count_ListCallback(FsEntry* fs, EListCallbackArg arg)
|
void count_ListCallback(FsEntry* fs, EListCallbackArg arg)
|
||||||
{
|
{
|
||||||
if(arg == EListCallbackArg_Pop) return;
|
if(arg == EListCallbackArg_Pop) return;
|
||||||
|
@ -401,8 +401,23 @@ static BOOL cflash_build_fat()
|
||||||
if(dataSectors<36*1024*1024/512)
|
if(dataSectors<36*1024*1024/512)
|
||||||
dataSectors = 36*1024*1024/512;
|
dataSectors = 36*1024*1024/512;
|
||||||
|
|
||||||
|
if(dataSectors>=(0x80000000>>9))
|
||||||
|
{
|
||||||
|
printf("error allocating memory for fat (%d KBytes)\n",(dataSectors*512)/1024);
|
||||||
|
printf("total fat sizes > 2GB are never going to work\n");
|
||||||
|
}
|
||||||
|
|
||||||
delete file;
|
delete file;
|
||||||
|
try
|
||||||
|
{
|
||||||
file = new EMUFILE_MEMORY(dataSectors*512);
|
file = new EMUFILE_MEMORY(dataSectors*512);
|
||||||
|
}
|
||||||
|
catch(std::bad_alloc)
|
||||||
|
{
|
||||||
|
printf("error allocating memory for fat (%d KBytes)\n",(dataSectors*512)/1024);
|
||||||
|
printf("(out of memory)\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
//file = new EMUFILE_FILE("c:\\temp.ima","rb+");
|
//file = new EMUFILE_FILE("c:\\temp.ima","rb+");
|
||||||
|
|
||||||
//format the disk
|
//format the disk
|
||||||
|
|
Loading…
Reference in New Issue