Removing duplicate code, cleanup, adding error messages

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@909 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2008-10-18 05:33:52 +00:00
parent cb14a17ff5
commit f257434b93
4 changed files with 134 additions and 167 deletions

View File

@ -71,19 +71,19 @@ wxBitmap wxBitmapFromMemoryRGBA(const unsigned char* data, int width, int height
} }
BEGIN_EVENT_TABLE(CMemcardManager, wxDialog) BEGIN_EVENT_TABLE(CMemcardManager, wxDialog)
EVT_CLOSE(CMemcardManager::OnClose) EVT_CLOSE(OnClose)
EVT_BUTTON(ID_COPYLEFT,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_COPYLEFT,CopyDeleteClick)
EVT_BUTTON(ID_COPYRIGHT,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_COPYRIGHT,CopyDeleteClick)
EVT_BUTTON(ID_FIXCHECKSUM,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_FIXCHECKSUM,CopyDeleteClick)
EVT_BUTTON(ID_DELETELEFT,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_DELETELEFT,CopyDeleteClick)
EVT_BUTTON(ID_DELETERIGHT,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_DELETERIGHT,CopyDeleteClick)
EVT_BUTTON(ID_GCIOPENRIGHT,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_SAVEIMPORTRIGHT,CopyDeleteClick)
EVT_BUTTON(ID_GCISAVERIGHT,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_SAVEEXPORTRIGHT,CopyDeleteClick)
EVT_BUTTON(ID_GCIOPENLEFT,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_SAVEIMPORTLEFT,CopyDeleteClick)
EVT_BUTTON(ID_GCISAVELEFT,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_SAVEEXPORTLEFT,CopyDeleteClick)
EVT_BUTTON(ID_CONVERTTOGCI,CMemcardManager::CopyDeleteClick) EVT_BUTTON(ID_CONVERTTOGCI,CopyDeleteClick)
EVT_FILEPICKER_CHANGED(ID_MEMCARD1PATH,CMemcardManager::OnPathChange) EVT_FILEPICKER_CHANGED(ID_MEMCARD1PATH,OnPathChange)
EVT_FILEPICKER_CHANGED(ID_MEMCARD2PATH,CMemcardManager::OnPathChange) EVT_FILEPICKER_CHANGED(ID_MEMCARD2PATH,OnPathChange)
END_EVENT_TABLE() END_EVENT_TABLE()
CMemcardManager::CMemcardManager(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) CMemcardManager::CMemcardManager(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
@ -116,10 +116,10 @@ void CMemcardManager::CreateGUIControls()
m_FixChecksum = new wxButton(this, ID_FIXCHECKSUM, wxT("<-Fix\nChecksum"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_FixChecksum = new wxButton(this, ID_FIXCHECKSUM, wxT("<-Fix\nChecksum"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_GciOpenLeft = new wxButton(this, ID_GCIOPENLEFT, wxT("<-Import GCI"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_SaveImportLeft = new wxButton(this, ID_SAVEIMPORTLEFT, wxT("<-Import GCI"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_GciSaveLeft = new wxButton(this, ID_GCISAVELEFT, wxT("<-Export GCI"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_SaveExportLeft = new wxButton(this, ID_SAVEEXPORTLEFT, wxT("<-Export GCI"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_GciOpenRight = new wxButton(this, ID_GCIOPENRIGHT, wxT("Import GCI->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_SaveImportRight = new wxButton(this, ID_SAVEIMPORTRIGHT, wxT("Import GCI->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_GciSaveRight = new wxButton(this, ID_GCISAVERIGHT, wxT("Export GCI->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_SaveExportRight = new wxButton(this, ID_SAVEEXPORTRIGHT, wxT("Export GCI->"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
//Added to test GCS and SAV import, until ImportFile is fixed //Added to test GCS and SAV import, until ImportFile is fixed
//rather than needing to import and then export //rather than needing to import and then export
m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, wxT("Convert to GCI"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, wxT("Convert to GCI"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
@ -155,13 +155,13 @@ void CMemcardManager::CreateGUIControls()
sButtons->AddStretchSpacer(1); sButtons->AddStretchSpacer(1);
sButtons->Add(m_FixChecksum, 0, wxEXPAND, 5); sButtons->Add(m_FixChecksum, 0, wxEXPAND, 5);
sButtons->AddStretchSpacer(1); sButtons->AddStretchSpacer(1);
sButtons->Add(m_GciOpenLeft, 0, wxEXPAND, 5); sButtons->Add(m_SaveImportLeft, 0, wxEXPAND, 5);
sButtons->Add(m_GciSaveLeft, 0, wxEXPAND, 5); sButtons->Add(m_SaveExportLeft, 0, wxEXPAND, 5);
sButtons->AddStretchSpacer(1); sButtons->AddStretchSpacer(1);
sButtons->Add(m_ConvertToGci, 0, wxEXPAND, 5); sButtons->Add(m_ConvertToGci, 0, wxEXPAND, 5);
sButtons->AddStretchSpacer(1); sButtons->AddStretchSpacer(1);
sButtons->Add(m_GciOpenRight, 0, wxEXPAND, 5); sButtons->Add(m_SaveImportRight, 0, wxEXPAND, 5);
sButtons->Add(m_GciSaveRight, 0, wxEXPAND, 5); sButtons->Add(m_SaveExportRight, 0, wxEXPAND, 5);
sButtons->AddStretchSpacer(1); sButtons->AddStretchSpacer(1);
sButtons->Add(m_DeleteLeft, 0, wxEXPAND, 5); sButtons->Add(m_DeleteLeft, 0, wxEXPAND, 5);
sButtons->Add(m_DeleteRight, 0, wxEXPAND, 5); sButtons->Add(m_DeleteRight, 0, wxEXPAND, 5);
@ -189,7 +189,6 @@ void CMemcardManager::OnClose(wxCloseEvent& WXUNUSED (event))
void CMemcardManager::OnPathChange(wxFileDirPickerEvent& event) void CMemcardManager::OnPathChange(wxFileDirPickerEvent& event)
{ {
switch (event.GetId()) switch (event.GetId())
{ {
case ID_MEMCARD1PATH: case ID_MEMCARD1PATH:
@ -203,25 +202,26 @@ void CMemcardManager::OnPathChange(wxFileDirPickerEvent& event)
void CMemcardManager::CopyDeleteClick(wxCommandEvent& event) void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
{ {
int index0 = m_MemcardList[0]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);; int index0 = m_MemcardList[0]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
int index1 = m_MemcardList[1]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);; int index1 = m_MemcardList[1]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
int slot = 1;
int index2 = index1;
char * fileName2 = NULL;
switch(event.GetId()) switch(event.GetId())
{ {
case ID_COPYLEFT: case ID_COPYLEFT:
if ((index1 != -1) && (memoryCard[0] != NULL)) slot=0;
{ index2 = index0;
memoryCard[0]->CopyFrom(*memoryCard[1], index1);
memoryCard[0]->Save();
ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0);
}
break;
case ID_COPYRIGHT: case ID_COPYRIGHT:
if ((index0 != -1) && (memoryCard[1] != NULL)) if ((index2 != -1) && (memoryCard[slot] != NULL))
{ {
memoryCard[1]->CopyFrom(*memoryCard[0], index0); int slot2;
memoryCard[1]->Save(); slot == 0 ? slot2=1:slot2=0;
ReloadMemcard(m_Memcard2Path->GetPath().mb_str(), 1); memoryCard[slot]->CopyFrom(*memoryCard[slot2], index2);
memoryCard[slot]->Save();
slot == 1 ? ReloadMemcard(m_Memcard2Path->GetPath().mb_str(), 1)
: ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0);
} }
break; break;
case ID_FIXCHECKSUM: case ID_FIXCHECKSUM:
@ -234,85 +234,74 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
} }
break; break;
case ID_CONVERTTOGCI: case ID_CONVERTTOGCI:
{ // Wont compile without brackets?? fileName2 = new char;
wxString temp = wxFileSelector(_T("Select the save file to convert"), case ID_SAVEIMPORTLEFT:
slot = 0;
case ID_SAVEIMPORTRIGHT:
if (memoryCard[slot] != NULL || fileName2 != NULL)
{
wxString temp = wxFileSelector(_T("Select the GCI file to import"),
wxEmptyString, wxEmptyString, wxEmptyString,wxString::Format wxEmptyString, wxEmptyString, wxEmptyString,wxString::Format
( (
_T("Gamecube save files(*.gcs,*.sav)|*.gcs;*.sav|" _T("Gamecube save files(*.gci,*.gcs,*.sav)|*.gci;*.gcs;*.sav|"
"Native GCI files (*.gci)|*.gci|"
"MadCatz Gameshark files(*.gcs)|*.gcs|" "MadCatz Gameshark files(*.gcs)|*.gcs|"
"Datel MaxDrive/Pro files(*.sav)|*.sav"), "Datel MaxDrive/Pro files(*.sav)|*.sav"),
wxFileSelectorDefaultWildcardStr, wxFileSelectorDefaultWildcardStr,
wxFileSelectorDefaultWildcardStr wxFileSelectorDefaultWildcardStr
), ),
wxFD_OPEN | wxFD_FILE_MUST_EXIST); wxFD_OPEN | wxFD_FILE_MUST_EXIST);
if (!temp.empty())
{
const char * fileName = temp.ToAscii(); const char * fileName = temp.ToAscii();
wxString temp2 = wxFileSelector(_T("Save GCI as.."), if (*fileName2 != NULL && !temp.empty())
wxEmptyString, wxEmptyString, _T(".gci"), wxString::Format {
( wxString temp2 = wxFileSelector(_T("Save GCI as.."),
_T("GCI File(*.gci)|*.gci"), wxEmptyString, wxEmptyString, _T(".gci"), wxString::Format
wxFileSelectorDefaultWildcardStr, (
wxFileSelectorDefaultWildcardStr _T("GCI File(*.gci)|*.gci"),
), wxFileSelectorDefaultWildcardStr,
wxFD_OVERWRITE_PROMPT|wxFD_SAVE); wxFileSelectorDefaultWildcardStr
const char * fileName2 = temp2.ToAscii(); ),
if (temp.length() > 0) wxFD_OVERWRITE_PROMPT|wxFD_SAVE);
delete fileName2;
fileName2 = (char*)temp2.ToAscii();
}
if (temp.length() > 0)
{
switch(memoryCard[slot]->ImportGci(fileName, fileName2))
{ {
memoryCard[0]->ImportGci(fileName, fileName2); case LENGTHFAIL:
wxMessageBox(wxT("Imported file has invalid length"),
wxT("Error"), wxOK|wxICON_ERROR);
break;
case GCSFAIL:
wxMessageBox(wxT("Imported file has gsc extension\nbut"
" does not have a correct header"), wxT("Error"),
wxOK|wxICON_ERROR);
break;
case SAVFAIL:
wxMessageBox(wxT("Imported file has sav extension\nbut"
" does not have a correct header"), wxT("Error"),
wxOK|wxICON_ERROR);
break;
case OPENFAIL:
wxMessageBox(wxT("Imported file could not be opened\nor"
" does not have a valid extension"), wxT("Error"),
wxOK|wxICON_ERROR);
break;
default:
memoryCard[slot]->Save();
slot == 1 ? ReloadMemcard(m_Memcard2Path->GetPath().mb_str(), 1)
: ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0);
break;
} }
}
}
break;
case ID_GCIOPENLEFT:
if (memoryCard[0] != NULL)
{
wxString temp = wxFileSelector(_T("Select the GCI file to import"),
wxEmptyString, wxEmptyString, wxEmptyString,wxString::Format
(
_T("Gamecube save files(*.gci,*.gcs,*.sav)|*.gci;*.gcs;*.sav|"
"Native GCI files (*.gci)|*.gci|"
"MadCatz Gameshark files(*.gcs)|*.gcs|"
"Datel MaxDrive/Pro files(*.sav)|*.sav"),
wxFileSelectorDefaultWildcardStr,
wxFileSelectorDefaultWildcardStr
),
wxFD_OPEN | wxFD_FILE_MUST_EXIST);
const char * fileName = temp.ToAscii();
if (temp.length() > 0)
{
memoryCard[0]->ImportGci(fileName, 0);
memoryCard[0]->Save();
ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0);
} }
} }
break; break;
case ID_GCIOPENRIGHT: case ID_SAVEEXPORTLEFT:
if (memoryCard[1] != NULL) slot=0;
{ index2 = index0;
wxString temp = wxFileSelector(_T("Select the GCI file to import"), case ID_SAVEEXPORTRIGHT:
wxEmptyString, wxEmptyString, wxEmptyString,wxString::Format if (index2 != -1)
(
_T("Gamecube save files(*.gci,*.gcs,*.sav)|*.gci;*.gcs;*.sav|"
"Native GCI files (*.gci)|*.gci|"
"MadCatz Gameshark files(*.gcs)|*.gcs|"
"Datel MaxDrive/Pro files(*.sav)|*.sav"),
wxFileSelectorDefaultWildcardStr,
wxFileSelectorDefaultWildcardStr
),
wxFD_OPEN | wxFD_FILE_MUST_EXIST);
const char * fileName = temp.ToAscii();
if (temp.length() > 0)
{
memoryCard[1]->ImportGci(fileName, 0);
memoryCard[1]->Save();
ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0);
}
}
break;
case ID_GCISAVELEFT:
if (index0 != -1)
{ {
wxString temp = wxFileSelector(_T("Save GCI as.."), wxString temp = wxFileSelector(_T("Save GCI as.."),
wxEmptyString, wxEmptyString, _T(".gci"), wxString::Format wxEmptyString, wxEmptyString, _T(".gci"), wxString::Format
@ -325,40 +314,19 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
const char * fileName = temp.ToAscii(); const char * fileName = temp.ToAscii();
if (temp.length() > 0) if (temp.length() > 0)
memoryCard[0]->ExportGci(index0, fileName); memoryCard[slot]->ExportGci(index2, fileName);
}
break;
case ID_GCISAVERIGHT:
if (index1 != -1)
{
wxString temp = wxFileSelector(_T("Save GCI as.."),
wxEmptyString, wxEmptyString, _T(".gci"), wxString::Format
(
_T("GCI File(*.gci)|*.gci"),
wxFileSelectorDefaultWildcardStr,
wxFileSelectorDefaultWildcardStr
),
wxFD_OVERWRITE_PROMPT|wxFD_SAVE);
const char * fileName = temp.ToAscii();
if (temp.length() > 0)
memoryCard[1]->ExportGci(index1, fileName);
} }
break; break;
case ID_DELETELEFT: case ID_DELETELEFT:
if (index0 != -1) slot=0;
{ index2 = index0;
memoryCard[0]->RemoveFile(index0);
memoryCard[0]->Save();
ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0);
}
break;
case ID_DELETERIGHT: case ID_DELETERIGHT:
if (index1 != -1) if (index2 != -1)
{ {
memoryCard[1]->RemoveFile(index1); memoryCard[slot]->RemoveFile(index2);
memoryCard[1]->Save(); memoryCard[slot]->Save();
ReloadMemcard(m_Memcard2Path->GetPath().mb_str(), 1); slot == 1 ? ReloadMemcard(m_Memcard2Path->GetPath().mb_str(), 1)
: ReloadMemcard(m_Memcard1Path->GetPath().mb_str(), 0);
} }
break; break;
} }
@ -416,9 +384,7 @@ void CMemcardManager::ReloadMemcard(const char *fileName, int card)
if (numFrames>0) if (numFrames>0)
{ {
memset(pxdata,0,96*32*4); memset(pxdata,0,96*32*4);
int frames=3; int frames=3;
if (numFrames<frames) frames=numFrames; if (numFrames<frames) frames=numFrames;
for (int f=0;f<frames;f++) for (int f=0;f<frames;f++)
{ {
@ -442,7 +408,6 @@ void CMemcardManager::ReloadMemcard(const char *fileName, int card)
if (!memoryCard[card]->GetComment1(i,title)) title[0]=0; if (!memoryCard[card]->GetComment1(i,title)) title[0]=0;
if (!memoryCard[card]->GetComment2(i,comment)) comment[0]=0; if (!memoryCard[card]->GetComment2(i,comment)) comment[0]=0;
int index = m_MemcardList[card]->InsertItem(i, wxT("row")); int index = m_MemcardList[card]->InsertItem(i, wxT("row"));
m_MemcardList[card]->SetItem(index, COLUMN_BANNER, wxEmptyString); m_MemcardList[card]->SetItem(index, COLUMN_BANNER, wxEmptyString);
m_MemcardList[card]->SetItem(index, COLUMN_TITLE, wxString::FromAscii(title)); m_MemcardList[card]->SetItem(index, COLUMN_TITLE, wxString::FromAscii(title));
@ -457,12 +422,10 @@ void CMemcardManager::ReloadMemcard(const char *fileName, int card)
} }
delete[] images; delete[] images;
// Automatic column width and then show the list // Automatic column width and then show the list
for (int i = 0; i < m_MemcardList[card]->GetColumnCount(); i++) for (int i = 0; i < m_MemcardList[card]->GetColumnCount(); i++)
{ {
m_MemcardList[card]->SetColumnWidth(i, wxLIST_AUTOSIZE); m_MemcardList[card]->SetColumnWidth(i, wxLIST_AUTOSIZE);
} }
m_MemcardList[card]->Show(); m_MemcardList[card]->Show();
} }

View File

@ -46,10 +46,10 @@ class CMemcardManager
wxButton *m_CopyLeft; wxButton *m_CopyLeft;
wxButton *m_CopyRight; wxButton *m_CopyRight;
wxButton *m_FixChecksum; wxButton *m_FixChecksum;
wxButton *m_GciOpenLeft; wxButton *m_SaveImportLeft;
wxButton *m_GciSaveLeft; wxButton *m_SaveExportLeft;
wxButton *m_GciOpenRight; wxButton *m_SaveImportRight;
wxButton *m_GciSaveRight; wxButton *m_SaveExportRight;
wxButton *m_ConvertToGci; wxButton *m_ConvertToGci;
wxButton *m_DeleteLeft; wxButton *m_DeleteLeft;
wxButton *m_DeleteRight; wxButton *m_DeleteRight;
@ -69,10 +69,10 @@ class CMemcardManager
ID_DELETELEFT, ID_DELETELEFT,
ID_MEMCARD1PATH, ID_MEMCARD1PATH,
ID_MEMCARD2PATH, ID_MEMCARD2PATH,
ID_GCISAVERIGHT, ID_SAVEEXPORTRIGHT,
ID_GCISAVELEFT, ID_SAVEEXPORTLEFT,
ID_GCIOPENRIGHT, ID_SAVEIMPORTRIGHT,
ID_GCIOPENLEFT, ID_SAVEIMPORTLEFT,
ID_CONVERTTOGCI, ID_CONVERTTOGCI,
ID_MEMCARD1LIST, ID_MEMCARD1LIST,
ID_MEMCARD2LIST, ID_MEMCARD2LIST,

View File

@ -75,13 +75,13 @@ void GCMemcard::calc_checksumsBE(u16 *buf, u32 num, u16 *c1, u16 *c2)
u32 GCMemcard::GetNumFiles() u32 GCMemcard::GetNumFiles()
{ {
if(!mcdFile) return 0; if(!mcdFile) return 0;
int j =0;
for(int i=0;i<126;i++) for(int i=0;i<126;i++)
{ {
if(BE32(dir.Dir[i].Gamecode)==0xFFFFFFFF) if(BE32(dir.Dir[i].Gamecode)!=0xFFFFFFFF)
return i; j++;
} }
return 127; return j;
} }
bool GCMemcard::RemoveFile(u32 index) //index in the directory array bool GCMemcard::RemoveFile(u32 index) //index in the directory array
@ -643,17 +643,11 @@ u32 GCMemcard::CopyFrom(GCMemcard& source, u32 index)
u32 GCMemcard::ImportGci(const char *fileName, const char *fileName2) u32 GCMemcard::ImportGci(const char *fileName, const char *fileName2)
{ {
if (!mcdFile && !fileName2) return 0; if (!mcdFile && !fileName2) return OPENFAIL;
FILE *gci = fopen(fileName, "rb"); FILE *gci = fopen(fileName, "rb");
if (!gci) return 0; if (!gci) return OPENFAIL;
enum
{
GCI = 0,
SAV = 0x80,
GCS = 0x110
};
int offset; int offset;
char * tmp = new char[0xD]; char * tmp = new char[0xD];
std::string fileType; std::string fileType;
@ -670,9 +664,7 @@ u32 GCMemcard::ImportGci(const char *fileName, const char *fileName2)
offset = GCS; offset = GCS;
else else
{ {
// TODO: Add error message return GCSFAIL;
// file has gsc extension but does not have a correct header
return 0;
} }
} }
else{ else{
@ -682,15 +674,12 @@ u32 GCMemcard::ImportGci(const char *fileName, const char *fileName2)
offset = SAV; offset = SAV;
else else
{ {
// TODO: Add error message return SAVFAIL;
//file has sav extension but does not have a correct header
return 0;
} }
} }
else else
{ {
// TODO: Add error message, file has invalid extension return OPENFAIL;
return 0;
} }
} }
} }
@ -734,10 +723,14 @@ u32 GCMemcard::ImportGci(const char *fileName, const char *fileName2)
default: default:
break; break;
} }
// TODO: verify file length if (length == BE16(d->BlockCount) * 0x2000)
assert(length == BE16(d->BlockCount) * 0x2000); {
assert(ftell(gci) == offset + 0x40); // Verify correct file position return LENGTHFAIL;
}
if (ftell(gci) == offset + 0x40) // Verify correct file position
{
return OPENFAIL;
}
u32 size = BE16((d->BlockCount)) * 0x2000; u32 size = BE16((d->BlockCount)) * 0x2000;
u8 *t = new u8[size]; u8 *t = new u8[size];
fread(t, 1, size, gci); fread(t, 1, size, gci);
@ -746,7 +739,7 @@ u32 GCMemcard::ImportGci(const char *fileName, const char *fileName2)
if(fileName2) if(fileName2)
{ {
FILE * gci2 = fopen(fileName2, "wb"); FILE * gci2 = fopen(fileName2, "wb");
if (!gci2) return 0; if (!gci2) return OPENFAIL;
fseek(gci2, 0, SEEK_SET); fseek(gci2, 0, SEEK_SET);
fwrite(d, 1, 0x40, gci2); fwrite(d, 1, 0x40, gci2);
int fileBlocks = BE16(d->BlockCount); int fileBlocks = BE16(d->BlockCount);

View File

@ -20,6 +20,17 @@
#include "Common.h" #include "Common.h"
#include "StringUtil.h" #include "StringUtil.h"
enum
{
LENGTHFAIL = -4,
GCSFAIL,
SAVFAIL,
OPENFAIL,
GCI,
SAV = 0x80,
GCS = 0x110
};
class GCMemcard class GCMemcard
{ {
void* mcdFile; void* mcdFile;