pcsx2: support both pnach and PNACH extension (linux is case sensitive...)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5642 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut 2013-05-25 08:33:30 +00:00
parent dfd4e9b216
commit 832016f757
1 changed files with 35 additions and 33 deletions

View File

@ -173,28 +173,30 @@ void ResetCheatsCount()
static int LoadCheatsFiles(const wxDirName& folderName, wxString& fileSpec, const wxString& friendlyName) static int LoadCheatsFiles(const wxDirName& folderName, wxString& fileSpec, const wxString& friendlyName)
{ {
if (!folderName.Exists()) { if (!folderName.Exists()) {
Console.WriteLn(Color_Red, L"The %s folder ('%s') is inaccessible. Skipping...", friendlyName.c_str(), folderName.ToString().c_str()); Console.WriteLn(Color_Red, L"The %s folder ('%s') is inaccessible. Skipping...", friendlyName.c_str(), folderName.ToString().c_str());
return 0; return 0;
} }
wxDir dir(folderName.ToString()); wxDir dir(folderName.ToString());
int before = cheatnumber; int before = cheatnumber;
wxString buffer; wxString buffer;
wxTextFile f; wxTextFile f;
bool found = dir.GetFirst(&buffer, fileSpec, wxDIR_FILES); bool found = dir.GetFirst(&buffer, fileSpec, wxDIR_FILES);
while (found) { while (found) {
Console.WriteLn(Color_Gray, L"Found %s file: '%s'", friendlyName.c_str(), buffer.c_str()); if (buffer.Matches(L"*.pnach") || buffer.Matches(L"*.PNACH")) {
int before = cheatnumber; Console.WriteLn(Color_Gray, L"Found %s file: '%s'", friendlyName.c_str(), buffer.c_str());
f.Open(Path::Combine(dir.GetName(), buffer)); int before = cheatnumber;
inifile_process(f); f.Open(Path::Combine(dir.GetName(), buffer));
f.Close(); inifile_process(f);
int loaded = cheatnumber - before; f.Close();
Console.WriteLn((loaded ? Color_Green : Color_Gray), L"Loaded %d %s from '%s'", loaded, friendlyName.c_str(), buffer.c_str()); int loaded = cheatnumber - before;
found = dir.GetNext(&buffer); Console.WriteLn((loaded ? Color_Green : Color_Gray), L"Loaded %d %s from '%s'", loaded, friendlyName.c_str(), buffer.c_str());
} }
found = dir.GetNext(&buffer);
}
return cheatnumber - before; return cheatnumber - before;
} }
// This routine loads cheats from *.pnach files // This routine loads cheats from *.pnach files
@ -202,23 +204,23 @@ static int LoadCheatsFiles(const wxDirName& folderName, wxString& fileSpec, cons
// Note: Should be called after InitPatches() // Note: Should be called after InitPatches()
int LoadCheats(wxString name, const wxDirName& folderName, const wxString& friendlyName) int LoadCheats(wxString name, const wxDirName& folderName, const wxString& friendlyName)
{ {
if (!name.Length()) { if (!name.Length()) {
Console.WriteLn(Color_Gray, "Cheats: No CRC, using 00000000 instead."); Console.WriteLn(Color_Gray, "Cheats: No CRC, using 00000000 instead.");
name = L"00000000"; name = L"00000000";
} }
int loaded = 0; int loaded = 0;
wxString filespec = name + L"*.pnach"; wxString filespec = name + L"*.*";
loaded += LoadCheatsFiles(folderName, filespec, friendlyName); loaded += LoadCheatsFiles(folderName, filespec, friendlyName);
if (wxFileName::IsCaseSensitive() && name != name.Upper()) { if (wxFileName::IsCaseSensitive() && name != name.Upper()) {
filespec = name.Upper() + L"*.pnach"; filespec = name.Upper() + L"*.*";
loaded += LoadCheatsFiles(folderName, filespec, friendlyName); loaded += LoadCheatsFiles(folderName, filespec, friendlyName);
} }
Console.WriteLn((loaded ? Color_Green : Color_Gray), L"Overall %d %s loaded", loaded, friendlyName.c_str()); Console.WriteLn((loaded ? Color_Green : Color_Gray), L"Overall %d %s loaded", loaded, friendlyName.c_str());
return loaded; return loaded;
} }
static u32 StrToU32(const wxString& str, int base = 10) static u32 StrToU32(const wxString& str, int base = 10)