Memcardmanager fixes. Fix for missing return values in switch statement, fix for return value from importfile

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1498 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2008-12-11 06:20:39 +00:00
parent 8b24a9b498
commit cf987d255d
3 changed files with 41 additions and 10 deletions

View File

@ -510,6 +510,22 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
memoryCard[SLOT_A]->Save(); memoryCard[SLOT_A]->Save();
ReloadMemcard(m_MemcardPath_A->GetPath().mb_str(), SLOT_A, FIRSTPAGE); ReloadMemcard(m_MemcardPath_A->GetPath().mb_str(), SLOT_A, FIRSTPAGE);
break; break;
case TITLEPRESENT:
wxMessageBox(wxT("Memcard already has a save for this title"),
wxT("Error"), wxOK|wxICON_ERROR);
break;
case INVALIDFILESIZE:
wxMessageBox(wxT("The save you are trying to copy has an invalid file size"),
wxT("Error"), wxOK|wxICON_ERROR);
case OUTOFBLOCKS:
blocksOpen.Printf(wxT("Only %d blocks available"), memoryCard[slot]->GetFreeBlocks());
wxMessageBox(blocksOpen, wxT("Error"), wxOK|wxICON_ERROR);
break;
case OUTOFDIRENTRIES:
wxMessageBox(wxT("No free dir index entries"),
wxT("Error"), wxOK|wxICON_ERROR);
default:
wxMessageBox(wxEmptyString, wxT("Error"), wxOK|wxICON_ERROR);
} }
} }
@ -535,6 +551,24 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
memoryCard[SLOT_B]->Save(); memoryCard[SLOT_B]->Save();
ReloadMemcard(m_MemcardPath_B->GetPath().mb_str(), SLOT_B, FIRSTPAGE); ReloadMemcard(m_MemcardPath_B->GetPath().mb_str(), SLOT_B, FIRSTPAGE);
break; break;
case TITLEPRESENT:
wxMessageBox(wxT("Memcard already has a save for this title"),
wxT("Error"), wxOK|wxICON_ERROR);
break;
case INVALIDFILESIZE:
wxMessageBox(wxT("The save you are trying to copy has an invalid file size"),
wxT("Error"), wxOK|wxICON_ERROR);
break;
case OUTOFBLOCKS:
blocksOpen.Printf(wxT("Only %d blocks available"), memoryCard[slot]->GetFreeBlocks());
wxMessageBox(blocksOpen, wxT("Error"), wxOK|wxICON_ERROR);
break;
case OUTOFDIRENTRIES:
wxMessageBox(wxT("No free dir index entries"),
wxT("Error"), wxOK|wxICON_ERROR);
break;
default:
wxMessageBox(wxEmptyString, wxT("Error"), wxOK|wxICON_ERROR);
} }
} }
else else

View File

@ -305,7 +305,7 @@ u32 GCMemcard::ImportFile(DEntry& direntry, u8* contents, int remove)
FixChecksums(); FixChecksums();
Save(); Save();
} }
return fileBlocks; return SUCCESS;
} }
u32 GCMemcard::GetFileData(u32 index, u8* dest, bool old) //index in the directory array u32 GCMemcard::GetFileData(u32 index, u8* dest, bool old) //index in the directory array
@ -665,10 +665,10 @@ u32 GCMemcard::CopyFrom(GCMemcard& source, u32 index)
if (!mcdFile) return NOMEMCARD; if (!mcdFile) return NOMEMCARD;
DEntry d; DEntry d;
if (!source.GetFileInfo(index, d)) return 0; if (!source.GetFileInfo(index, d)) return NOMEMCARD;
u32 size = source.GetFileSize(index); u32 size = source.GetFileSize(index);
if (size == 0xFFFF) return 0; if (size == 0xFFFF) return INVALIDFILESIZE;
u8 *t = new u8[size * 0x2000]; u8 *t = new u8[size * 0x2000];
switch (source.GetFileData(index, t, true)) switch (source.GetFileData(index, t, true))
@ -680,14 +680,10 @@ u32 GCMemcard::CopyFrom(GCMemcard& source, u32 index)
delete[] t; delete[] t;
return NOMEMCARD; return NOMEMCARD;
default: default:
break; u32 ret = ImportFile(d,t,0);
delete[] t;
return ret;
} }
u32 ret = ImportFile(d,t,0);
delete[] t;
return ret;
} }
s32 GCMemcard::ImportGci(const char *fileName, std::string fileName2) s32 GCMemcard::ImportGci(const char *fileName, std::string fileName2)

View File

@ -44,6 +44,7 @@ enum
OUTOFDIRENTRIES, OUTOFDIRENTRIES,
NOMEMCARD, NOMEMCARD,
NOFILE, NOFILE,
INVALIDFILESIZE,
TITLEPRESENT, TITLEPRESENT,
SUCCESS = 0x2000, SUCCESS = 0x2000,
FAIL, FAIL,