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