folderMemoryCard: hack - don't hang PCSX2 if a file has zero size

I'm not sure if it breaks the state of the folderMemoryCard (FMC) or not, but
at least it doesn't hang PCSX2.

Might need followup to make sure the state ends up valid.
This commit is contained in:
Avi Halachmi (:avih) 2015-09-19 13:01:19 +03:00
parent e576f259e4
commit ef9016e363
1 changed files with 5 additions and 0 deletions

View File

@ -413,6 +413,11 @@ bool FolderMemoryCard::AddFile( MemoryCardFileEntry* const dirEntry, const wxStr
// make sure we have enough space on the memcard to hold the data
const u32 clusterSize = m_superBlock.data.pages_per_cluster * m_superBlock.data.page_len;
const u32 filesize = file.Length();
if (!filesize) {
Console.Error(L"(MCDF) Empty file. Aborting.");
file.Close();
return false;
}
const u32 countClusters = ( filesize % clusterSize ) != 0 ? ( filesize / clusterSize + 1 ) : ( filesize / clusterSize );
const u32 newNeededClusters = ( dirEntry->entry.data.length % 2 ) == 0 ? countClusters + 1 : countClusters;
if ( newNeededClusters > GetAmountFreeDataClusters() ) {