mirror of https://github.com/PCSX2/pcsx2.git
CDVD: Purge wxString
This commit is contained in:
parent
a635e84d82
commit
63424b765d
|
@ -49,7 +49,7 @@
|
||||||
// (examples: SLUS-2113, etc).
|
// (examples: SLUS-2113, etc).
|
||||||
// If the disc is homebrew then it probably won't have a valid serial; in which case
|
// If the disc is homebrew then it probably won't have a valid serial; in which case
|
||||||
// this string will be empty.
|
// this string will be empty.
|
||||||
wxString DiscSerial;
|
std::string DiscSerial;
|
||||||
|
|
||||||
cdvdStruct cdvd;
|
cdvdStruct cdvd;
|
||||||
|
|
||||||
|
@ -375,10 +375,14 @@ s32 cdvdWriteConfig(const u8* config)
|
||||||
static MutexRecursive Mutex_NewDiskCB;
|
static MutexRecursive Mutex_NewDiskCB;
|
||||||
|
|
||||||
// Sets ElfCRC to the CRC of the game bound to the CDVD source.
|
// Sets ElfCRC to the CRC of the game bound to the CDVD source.
|
||||||
static __fi ElfObject* loadElf(const wxString filename, bool isPSXElf)
|
static __fi ElfObject* loadElf(std::string filename, bool isPSXElf)
|
||||||
{
|
{
|
||||||
if (filename.StartsWith(L"host"))
|
if (StringUtil::StartsWith(filename, "host:"))
|
||||||
return new ElfObject(filename.After(':'), FileSystem::GetPathFileSize(filename.After(':').ToUTF8()), isPSXElf);
|
{
|
||||||
|
std::string host_filename(filename.substr(5));
|
||||||
|
s64 host_size = FileSystem::GetPathFileSize(host_filename.c_str());
|
||||||
|
return new ElfObject(std::move(host_filename), static_cast<u32>(std::max<s64>(host_size, 0)), isPSXElf);
|
||||||
|
}
|
||||||
|
|
||||||
// Mimic PS2 behavior!
|
// Mimic PS2 behavior!
|
||||||
// Much trial-and-error with changing the ISOFS and BOOT2 contents of an image have shown that
|
// Much trial-and-error with changing the ISOFS and BOOT2 contents of an image have shown that
|
||||||
|
@ -394,41 +398,35 @@ static __fi ElfObject* loadElf(const wxString filename, bool isPSXElf)
|
||||||
// FIXME: Properly mimicing this behavior is troublesome since we need to add support for "ignoring"
|
// FIXME: Properly mimicing this behavior is troublesome since we need to add support for "ignoring"
|
||||||
// version information when doing file searches. I'll add this later. For now, assuming a ;1 should
|
// version information when doing file searches. I'll add this later. For now, assuming a ;1 should
|
||||||
// be sufficient (no known games have their ELF binary as anything but version ;1)
|
// be sufficient (no known games have their ELF binary as anything but version ;1)
|
||||||
|
const std::string::size_type semi_pos = filename.rfind(';');
|
||||||
const wxString fixedname(wxStringTokenizer(filename, L';').GetNextToken() + L";1");
|
if (semi_pos != std::string::npos && std::string_view(filename).substr(semi_pos) != ";1")
|
||||||
|
{
|
||||||
if (fixedname != filename)
|
Console.WriteLn(Color_Blue, "(LoadELF) Non-conforming version suffix (%s) detected and replaced.", filename.c_str());
|
||||||
Console.WriteLn(Color_Blue, "(LoadELF) Non-conforming version suffix detected and replaced.");
|
filename.erase(semi_pos);
|
||||||
|
filename += ";1";
|
||||||
|
}
|
||||||
|
|
||||||
IsoFSCDVD isofs;
|
IsoFSCDVD isofs;
|
||||||
IsoFile file(isofs, fixedname);
|
IsoFile file(isofs, filename);
|
||||||
return new ElfObject(fixedname, file, isPSXElf);
|
return new ElfObject(std::move(filename), file, isPSXElf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __fi void _reloadElfInfo(wxString elfpath)
|
static __fi void _reloadElfInfo(std::string elfpath)
|
||||||
{
|
{
|
||||||
// Now's a good time to reload the ELF info...
|
// Now's a good time to reload the ELF info...
|
||||||
ScopedLock locker(Mutex_NewDiskCB);
|
ScopedLock locker(Mutex_NewDiskCB);
|
||||||
|
|
||||||
if (elfpath == LastELF)
|
if (elfpath == LastELF)
|
||||||
return;
|
return;
|
||||||
LastELF = elfpath;
|
|
||||||
|
|
||||||
wxString fname = elfpath.AfterLast('\\');
|
|
||||||
if (!fname)
|
|
||||||
fname = elfpath.AfterLast('/');
|
|
||||||
if (!fname)
|
|
||||||
fname = elfpath.AfterLast(':');
|
|
||||||
if (fname.Matches(L"????_???.??*"))
|
|
||||||
DiscSerial = fname(0, 4) + L"-" + fname(5, 3) + fname(9, 2);
|
|
||||||
std::unique_ptr<ElfObject> elfptr(loadElf(elfpath, false));
|
std::unique_ptr<ElfObject> elfptr(loadElf(elfpath, false));
|
||||||
|
|
||||||
|
|
||||||
elfptr->loadHeaders();
|
elfptr->loadHeaders();
|
||||||
ElfCRC = elfptr->getCRC();
|
ElfCRC = elfptr->getCRC();
|
||||||
ElfEntry = elfptr->header.e_entry;
|
ElfEntry = elfptr->header.e_entry;
|
||||||
ElfTextRange = elfptr->getTextRange();
|
ElfTextRange = elfptr->getTextRange();
|
||||||
Console.WriteLn(Color_StrongBlue, L"ELF (%s) Game CRC = 0x%08X, EntryPoint = 0x%08X", WX_STR(elfpath), ElfCRC, ElfEntry);
|
LastELF = std::move(elfpath);
|
||||||
|
|
||||||
|
Console.WriteLn(Color_StrongBlue, "ELF (%s) Game CRC = 0x%08X, EntryPoint = 0x%08X", LastELF.c_str(), ElfCRC, ElfEntry);
|
||||||
|
|
||||||
// Note: Do not load game database info here. This code is generic and called from
|
// Note: Do not load game database info here. This code is generic and called from
|
||||||
// BIOS key encryption as well as eeloadReplaceOSDSYS. The first is actually still executing
|
// BIOS key encryption as well as eeloadReplaceOSDSYS. The first is actually still executing
|
||||||
|
@ -437,27 +435,21 @@ static __fi void _reloadElfInfo(wxString elfpath)
|
||||||
// binary).
|
// binary).
|
||||||
}
|
}
|
||||||
|
|
||||||
static __fi void _reloadPSXElfInfo(wxString elfpath)
|
static __fi void _reloadPSXElfInfo(std::string elfpath)
|
||||||
{
|
{
|
||||||
// Now's a good time to reload the ELF info...
|
// Now's a good time to reload the ELF info...
|
||||||
ScopedLock locker(Mutex_NewDiskCB);
|
ScopedLock locker(Mutex_NewDiskCB);
|
||||||
|
|
||||||
if (elfpath == LastELF)
|
if (elfpath == LastELF)
|
||||||
return;
|
return;
|
||||||
LastELF = elfpath;
|
|
||||||
wxString fname = elfpath.AfterLast('\\');
|
|
||||||
if (!fname)
|
|
||||||
fname = elfpath.AfterLast('/');
|
|
||||||
if (!fname)
|
|
||||||
fname = elfpath.AfterLast(':');
|
|
||||||
if (fname.Matches(L"????_???.??*"))
|
|
||||||
DiscSerial = fname(0, 4) + L"-" + fname(5, 3) + fname(9, 2);
|
|
||||||
|
|
||||||
std::unique_ptr<ElfObject> elfptr(loadElf(elfpath, true));
|
std::unique_ptr<ElfObject> elfptr(loadElf(elfpath, true));
|
||||||
|
|
||||||
ElfCRC = elfptr->getCRC();
|
ElfCRC = elfptr->getCRC();
|
||||||
ElfTextRange = elfptr->getTextRange();
|
ElfTextRange = elfptr->getTextRange();
|
||||||
Console.WriteLn(Color_StrongBlue, L"PSX ELF (%s) Game CRC = 0x%08X", WX_STR(elfpath), ElfCRC);
|
LastELF = std::move(elfpath);
|
||||||
|
|
||||||
|
Console.WriteLn(Color_StrongBlue, "PSX ELF (%s) Game CRC = 0x%08X", LastELF.c_str(), ElfCRC);
|
||||||
|
|
||||||
// Note: Do not load game database info here. This code is generic and called from
|
// Note: Do not load game database info here. This code is generic and called from
|
||||||
// BIOS key encryption as well as eeloadReplaceOSDSYS. The first is actually still executing
|
// BIOS key encryption as well as eeloadReplaceOSDSYS. The first is actually still executing
|
||||||
|
@ -490,6 +482,11 @@ static std::string ExecutablePathToSerial(const std::string& path)
|
||||||
if (pos != std::string::npos)
|
if (pos != std::string::npos)
|
||||||
serial.erase(pos);
|
serial.erase(pos);
|
||||||
|
|
||||||
|
// check that it matches our expected format.
|
||||||
|
// this maintains the old behavior of PCSX2.
|
||||||
|
if (!StringUtil::WildcardMatch(serial.c_str(), "????_???.??*"))
|
||||||
|
serial.clear();
|
||||||
|
|
||||||
// SCES_123.45 -> SCES-12345
|
// SCES_123.45 -> SCES-12345
|
||||||
for (std::string::size_type pos = 0; pos < serial.size();)
|
for (std::string::size_type pos = 0; pos < serial.size();)
|
||||||
{
|
{
|
||||||
|
@ -510,31 +507,30 @@ static std::string ExecutablePathToSerial(const std::string& path)
|
||||||
return serial;
|
return serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cdvdReloadElfInfo(wxString elfoverride)
|
void cdvdReloadElfInfo(std::string elfoverride)
|
||||||
{
|
{
|
||||||
// called from context of executing VM code (recompilers), so we need to trap exceptions
|
// called from context of executing VM code (recompilers), so we need to trap exceptions
|
||||||
// and route them through the VM's exception handler. (needed for non-SEH platforms, such
|
// and route them through the VM's exception handler. (needed for non-SEH platforms, such
|
||||||
// as Linux/GCC)
|
// as Linux/GCC)
|
||||||
DevCon.WriteLn(Color_Green, L"Reload ELF");
|
DevCon.WriteLn(Color_Green, "Reload ELF");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!elfoverride.IsEmpty())
|
if (!elfoverride.empty())
|
||||||
{
|
{
|
||||||
_reloadElfInfo(elfoverride);
|
_reloadElfInfo(std::move(elfoverride));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string elfpath;
|
std::string elfpath;
|
||||||
u32 discType = GetPS2ElfName(elfpath);
|
u32 discType = GetPS2ElfName(elfpath);
|
||||||
|
DiscSerial = ExecutablePathToSerial(elfpath);
|
||||||
|
|
||||||
if (discType == 1)
|
if (discType == 1)
|
||||||
{
|
{
|
||||||
// PCSX2 currently only recognizes *.elf executables in proper PS2 format.
|
// PCSX2 currently only recognizes *.elf executables in proper PS2 format.
|
||||||
// To support different PSX titles in the console title and for savestates, this code bypasses all the detection,
|
// To support different PSX titles in the console title and for savestates, this code bypasses all the detection,
|
||||||
// simply using the exe name, stripped of problematic characters.
|
// simply using the exe name, stripped of problematic characters.
|
||||||
const std::string serial(ExecutablePathToSerial(elfpath));
|
_reloadPSXElfInfo(std::move(elfpath));
|
||||||
DiscSerial = StringUtil::UTF8StringToWxString(serial);
|
|
||||||
_reloadPSXElfInfo(StringUtil::UTF8StringToWxString(elfpath));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,7 +539,7 @@ void cdvdReloadElfInfo(wxString elfoverride)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Recognized and PS2 (BOOT2). Good job, user.
|
// Recognized and PS2 (BOOT2). Good job, user.
|
||||||
_reloadElfInfo(StringUtil::UTF8StringToWxString(elfpath));
|
_reloadElfInfo(std::move(elfpath));
|
||||||
}
|
}
|
||||||
catch (Exception::FileNotFound& e)
|
catch (Exception::FileNotFound& e)
|
||||||
{
|
{
|
||||||
|
@ -562,18 +558,6 @@ void cdvdReloadElfInfo(wxString elfoverride)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __fi s32 StrToS32(const wxString& str, int base = 10)
|
|
||||||
{
|
|
||||||
long l;
|
|
||||||
if (!str.ToLong(&l, base))
|
|
||||||
{
|
|
||||||
Console.Error(L"StrToS32: fail to translate '%s' as long", WX_STR(str));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cdvdReadKey(u8, u16, u32 arg2, u8* key)
|
void cdvdReadKey(u8, u16, u32 arg2, u8* key)
|
||||||
{
|
{
|
||||||
s32 numbers = 0, letters = 0;
|
s32 numbers = 0, letters = 0;
|
||||||
|
@ -585,17 +569,17 @@ void cdvdReadKey(u8, u16, u32 arg2, u8* key)
|
||||||
// clear key values
|
// clear key values
|
||||||
memset(key, 0, 16);
|
memset(key, 0, 16);
|
||||||
|
|
||||||
if (!DiscSerial.IsEmpty())
|
if (!DiscSerial.empty())
|
||||||
{
|
{
|
||||||
// convert the number characters to a real 32 bit number
|
// convert the number characters to a real 32 bit number
|
||||||
numbers = StrToS32(DiscSerial(5, 5));
|
numbers = StringUtil::FromChars<s32>(std::string_view(DiscSerial).substr(5, 5)).value_or(0);
|
||||||
|
|
||||||
// combine the lower 7 bits of each char
|
// combine the lower 7 bits of each char
|
||||||
// to make the 4 letters fit into a single u32
|
// to make the 4 letters fit into a single u32
|
||||||
letters = (s32)((DiscSerial[3].GetValue() & 0x7F) << 0) |
|
letters = (s32)((DiscSerial[3] & 0x7F) << 0) |
|
||||||
(s32)((DiscSerial[2].GetValue() & 0x7F) << 7) |
|
(s32)((DiscSerial[2] & 0x7F) << 7) |
|
||||||
(s32)((DiscSerial[1].GetValue() & 0x7F) << 14) |
|
(s32)((DiscSerial[1] & 0x7F) << 14) |
|
||||||
(s32)((DiscSerial[0].GetValue() & 0x7F) << 21);
|
(s32)((DiscSerial[0] & 0x7F) << 21);
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate magic numbers
|
// calculate magic numbers
|
||||||
|
|
|
@ -13,12 +13,13 @@
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#include "CDVDaccess.h"
|
#include "CDVDaccess.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
#define btoi(b) ((b) / 16 * 10 + (b) % 16) /* BCD to u_char */
|
#define btoi(b) ((b) / 16 * 10 + (b) % 16) /* BCD to u_char */
|
||||||
#define itob(i) ((i) / 10 * 16 + (i) % 10) /* u_char to BCD */
|
#define itob(i) ((i) / 10 * 16 + (i) % 10) /* u_char to BCD */
|
||||||
|
|
||||||
|
@ -175,8 +176,8 @@ extern void cdvdNewDiskCB();
|
||||||
extern u8 cdvdRead(u8 key);
|
extern u8 cdvdRead(u8 key);
|
||||||
extern void cdvdWrite(u8 key, u8 rt);
|
extern void cdvdWrite(u8 key, u8 rt);
|
||||||
|
|
||||||
extern void cdvdReloadElfInfo(wxString elfoverride = wxEmptyString);
|
extern void cdvdReloadElfInfo(std::string elfoverride = std::string());
|
||||||
extern s32 cdvdCtrlTrayOpen();
|
extern s32 cdvdCtrlTrayOpen();
|
||||||
extern s32 cdvdCtrlTrayClose();
|
extern s32 cdvdCtrlTrayClose();
|
||||||
|
|
||||||
extern wxString DiscSerial;
|
extern std::string DiscSerial;
|
||||||
|
|
|
@ -84,7 +84,7 @@ static int CheckDiskTypeFS(int baseType)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsoFile file(rootdir, L"SYSTEM.CNF;1");
|
IsoFile file(rootdir, "SYSTEM.CNF;1");
|
||||||
|
|
||||||
const int size = file.getLength();
|
const int size = file.getLength();
|
||||||
const std::unique_ptr<char[]> buffer = std::make_unique<char[]>(size + 1);
|
const std::unique_ptr<char[]> buffer = std::make_unique<char[]>(size + 1);
|
||||||
|
@ -109,7 +109,7 @@ static int CheckDiskTypeFS(int baseType)
|
||||||
// PS2 Linux disc 2, doesn't have a System.CNF or a normal ELF
|
// PS2 Linux disc 2, doesn't have a System.CNF or a normal ELF
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsoFile file(rootdir, L"P2L_0100.02;1");
|
IsoFile file(rootdir, "P2L_0100.02;1");
|
||||||
return CDVD_TYPE_PS2DVD;
|
return CDVD_TYPE_PS2DVD;
|
||||||
}
|
}
|
||||||
catch (Exception::FileNotFound&)
|
catch (Exception::FileNotFound&)
|
||||||
|
@ -118,7 +118,7 @@ static int CheckDiskTypeFS(int baseType)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsoFile file(rootdir, L"PSX.EXE;1");
|
IsoFile file(rootdir, "PSX.EXE;1");
|
||||||
return CDVD_TYPE_PSCD;
|
return CDVD_TYPE_PSCD;
|
||||||
}
|
}
|
||||||
catch (Exception::FileNotFound&)
|
catch (Exception::FileNotFound&)
|
||||||
|
@ -127,7 +127,7 @@ static int CheckDiskTypeFS(int baseType)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IsoFile file(rootdir, L"VIDEO_TS/VIDEO_TS.IFO;1");
|
IsoFile file(rootdir, "VIDEO_TS/VIDEO_TS.IFO;1");
|
||||||
return CDVD_TYPE_DVDV;
|
return CDVD_TYPE_DVDV;
|
||||||
}
|
}
|
||||||
catch (Exception::FileNotFound&)
|
catch (Exception::FileNotFound&)
|
||||||
|
@ -390,8 +390,8 @@ bool DoCDVDopen()
|
||||||
//FWIW Disc serial availability doesn't seem reliable enough, sometimes it's there and sometime it's just null
|
//FWIW Disc serial availability doesn't seem reliable enough, sometimes it's there and sometime it's just null
|
||||||
//Shouldn't the serial be available all time? Potentially need to look into Elfreloadinfo() reliability
|
//Shouldn't the serial be available all time? Potentially need to look into Elfreloadinfo() reliability
|
||||||
//TODO: Add extra fallback case for CRC.
|
//TODO: Add extra fallback case for CRC.
|
||||||
if (somepick.empty() && !DiscSerial.IsEmpty())
|
if (somepick.empty() && !DiscSerial.empty())
|
||||||
somepick = StringUtil::StdStringFromFormat("Untitled-%s", DiscSerial.ToUTF8().data());
|
somepick = StringUtil::StdStringFromFormat("Untitled-%s", DiscSerial.c_str());
|
||||||
else if (somepick.empty())
|
else if (somepick.empty())
|
||||||
somepick = "Untitled";
|
somepick = "Untitled";
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/Pcsx2Defs.h"
|
||||||
|
#include <string_view>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
enum IsoFS_Type
|
enum IsoFS_Type
|
||||||
{
|
{
|
||||||
FStype_ISO9660 = 1,
|
FStype_ISO9660 = 1,
|
||||||
|
@ -33,21 +37,21 @@ public:
|
||||||
IsoDirectory(SectorSource& r, IsoFileDescriptor directoryEntry);
|
IsoDirectory(SectorSource& r, IsoFileDescriptor directoryEntry);
|
||||||
virtual ~IsoDirectory() = default;
|
virtual ~IsoDirectory() = default;
|
||||||
|
|
||||||
wxString FStype_ToString() const;
|
std::string FStype_ToString() const;
|
||||||
SectorSource& GetReader() const { return internalReader; }
|
SectorSource& GetReader() const { return internalReader; }
|
||||||
|
|
||||||
bool Exists(const wxString& filePath) const;
|
bool Exists(const std::string_view& filePath) const;
|
||||||
bool IsFile(const wxString& filePath) const;
|
bool IsFile(const std::string_view& filePath) const;
|
||||||
bool IsDir(const wxString& filePath) const;
|
bool IsDir(const std::string_view& filePath) const;
|
||||||
|
|
||||||
u32 GetFileSize(const wxString& filePath) const;
|
u32 GetFileSize(const std::string_view& filePath) const;
|
||||||
|
|
||||||
IsoFileDescriptor FindFile(const wxString& filePath) const;
|
IsoFileDescriptor FindFile(const std::string_view& filePath) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const IsoFileDescriptor& GetEntry(const wxString& fileName) const;
|
const IsoFileDescriptor& GetEntry(const std::string_view& fileName) const;
|
||||||
const IsoFileDescriptor& GetEntry(int index) const;
|
const IsoFileDescriptor& GetEntry(int index) const;
|
||||||
|
|
||||||
void Init(const IsoFileDescriptor& directoryEntry);
|
void Init(const IsoFileDescriptor& directoryEntry);
|
||||||
int GetIndexOf(const wxString& fileName) const;
|
int GetIndexOf(const std::string_view& fileName) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
|
|
||||||
#include "IsoFS.h"
|
#include "IsoFS.h"
|
||||||
#include "IsoFile.h"
|
#include "IsoFile.h"
|
||||||
|
|
||||||
|
#include "common/FileSystem.h"
|
||||||
|
#include "common/StringUtil.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -28,19 +32,17 @@
|
||||||
//u8 volID[5]; // "CD001"
|
//u8 volID[5]; // "CD001"
|
||||||
|
|
||||||
|
|
||||||
wxString IsoDirectory::FStype_ToString() const
|
std::string IsoDirectory::FStype_ToString() const
|
||||||
{
|
{
|
||||||
switch (m_fstype)
|
switch (m_fstype)
|
||||||
{
|
{
|
||||||
case FStype_ISO9660:
|
case FStype_ISO9660:
|
||||||
return L"ISO9660";
|
return "ISO9660";
|
||||||
break;
|
|
||||||
case FStype_Joliet:
|
case FStype_Joliet:
|
||||||
return L"Joliet";
|
return "Joliet";
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxsFormat(L"Unrecognized Code (0x%x)", m_fstype);
|
return StringUtil::StdStringFromFormat("Unrecognized Code (0x%x)", m_fstype);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to load the Root directory from an image
|
// Used to load the Root directory from an image
|
||||||
|
@ -99,10 +101,10 @@ IsoDirectory::IsoDirectory(SectorSource& r)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
throw Exception::FileNotFound(L"IsoFileSystem") // FIXME: Should report the name of the ISO here...
|
throw Exception::FileNotFound("IsoFileSystem") // FIXME: Should report the name of the ISO here...
|
||||||
.SetDiagMsg(L"IsoFS could not find the root directory on the ISO image.");
|
.SetDiagMsg("IsoFS could not find the root directory on the ISO image.");
|
||||||
|
|
||||||
DevCon.WriteLn(L"(IsoFS) Filesystem is " + FStype_ToString());
|
DevCon.WriteLn("(IsoFS) Filesystem is %s", FStype_ToString().c_str());
|
||||||
Init(rootDirEntry);
|
Init(rootDirEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +151,7 @@ const IsoFileDescriptor& IsoDirectory::GetEntry(int index) const
|
||||||
return files[index];
|
return files[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
int IsoDirectory::GetIndexOf(const wxString& fileName) const
|
int IsoDirectory::GetIndexOf(const std::string_view& fileName) const
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < files.size(); i++)
|
for (unsigned int i = 0; i < files.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -157,21 +159,22 @@ int IsoDirectory::GetIndexOf(const wxString& fileName) const
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw Exception::FileNotFound(fileName);
|
throw Exception::FileNotFound(StringUtil::UTF8StringToWideString(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
const IsoFileDescriptor& IsoDirectory::GetEntry(const wxString& fileName) const
|
const IsoFileDescriptor& IsoDirectory::GetEntry(const std::string_view& fileName) const
|
||||||
{
|
{
|
||||||
return GetEntry(GetIndexOf(fileName));
|
return GetEntry(GetIndexOf(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
IsoFileDescriptor IsoDirectory::FindFile(const wxString& filePath) const
|
IsoFileDescriptor IsoDirectory::FindFile(const std::string_view& filePath) const
|
||||||
{
|
{
|
||||||
pxAssert(!filePath.IsEmpty());
|
if (filePath.empty())
|
||||||
|
throw Exception::FileNotFound();
|
||||||
|
|
||||||
// wxWidgets DOS-style parser should work fine for ISO 9660 path names. Only practical difference
|
// wxWidgets DOS-style parser should work fine for ISO 9660 path names. Only practical difference
|
||||||
// is case sensitivity, and that won't matter for path splitting.
|
// is case sensitivity, and that won't matter for path splitting.
|
||||||
wxFileName parts(filePath, wxPATH_DOS);
|
std::vector<std::string_view> parts(FileSystem::SplitWindowsPath(filePath));
|
||||||
IsoFileDescriptor info;
|
IsoFileDescriptor info;
|
||||||
const IsoDirectory* dir = this;
|
const IsoDirectory* dir = this;
|
||||||
std::unique_ptr<IsoDirectory> deleteme;
|
std::unique_ptr<IsoDirectory> deleteme;
|
||||||
|
@ -179,37 +182,38 @@ IsoFileDescriptor IsoDirectory::FindFile(const wxString& filePath) const
|
||||||
// walk through path ("." and ".." entries are in the directories themselves, so even if the
|
// walk through path ("." and ".." entries are in the directories themselves, so even if the
|
||||||
// path included . and/or .., it still works)
|
// path included . and/or .., it still works)
|
||||||
|
|
||||||
for (uint i = 0; i < parts.GetDirCount(); ++i)
|
// ignore the device (cdrom0:\)
|
||||||
|
const bool has_device = (parts.front().back() == ':');
|
||||||
|
|
||||||
|
for (size_t index = has_device ? 1 : 0; index < (parts.size() - 1); index++)
|
||||||
{
|
{
|
||||||
info = dir->GetEntry(parts.GetDirs()[i]);
|
info = dir->GetEntry(parts[index]);
|
||||||
if (info.IsFile())
|
if (info.IsFile())
|
||||||
throw Exception::FileNotFound(filePath);
|
throw Exception::FileNotFound(StringUtil::UTF8StringToWxString(filePath));
|
||||||
|
|
||||||
deleteme.reset(new IsoDirectory(internalReader, info));
|
deleteme.reset(new IsoDirectory(internalReader, info));
|
||||||
dir = deleteme.get();
|
dir = deleteme.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parts.GetFullName().IsEmpty())
|
info = dir->GetEntry(parts.back());
|
||||||
info = dir->GetEntry(parts.GetFullName());
|
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsoDirectory::IsFile(const wxString& filePath) const
|
bool IsoDirectory::IsFile(const std::string_view& filePath) const
|
||||||
{
|
{
|
||||||
if (filePath.IsEmpty())
|
if (filePath.empty())
|
||||||
return false;
|
return false;
|
||||||
return (FindFile(filePath).flags & 2) != 2;
|
return (FindFile(filePath).flags & 2) != 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsoDirectory::IsDir(const wxString& filePath) const
|
bool IsoDirectory::IsDir(const std::string_view& filePath) const
|
||||||
{
|
{
|
||||||
if (filePath.IsEmpty())
|
if (filePath.empty())
|
||||||
return false;
|
return false;
|
||||||
return (FindFile(filePath).flags & 2) == 2;
|
return (FindFile(filePath).flags & 2) == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 IsoDirectory::GetFileSize(const wxString& filePath) const
|
u32 IsoDirectory::GetFileSize(const std::string_view& filePath) const
|
||||||
{
|
{
|
||||||
return FindFile(filePath).size;
|
return FindFile(filePath).size;
|
||||||
}
|
}
|
||||||
|
@ -251,13 +255,14 @@ void IsoFileDescriptor::Load(const u8* data, int length)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
name = L".";
|
name = ".";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
name = L"..";
|
name = "..";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
name = (wxChar)c;
|
name = static_cast<char>(c);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -265,12 +270,6 @@ void IsoFileDescriptor::Load(const u8* data, int length)
|
||||||
// copy string and up-convert from ascii to wxChar
|
// copy string and up-convert from ascii to wxChar
|
||||||
|
|
||||||
const u8* fnsrc = data + 33;
|
const u8* fnsrc = data + 33;
|
||||||
const u8* fnend = fnsrc + fileNameLength;
|
name.assign(reinterpret_cast<const char*>(fnsrc), fileNameLength);
|
||||||
|
|
||||||
while (fnsrc != fnend)
|
|
||||||
{
|
|
||||||
name += (wxChar)*fnsrc;
|
|
||||||
++fnsrc;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,14 @@
|
||||||
#include "IsoFS.h"
|
#include "IsoFS.h"
|
||||||
#include "IsoFile.h"
|
#include "IsoFile.h"
|
||||||
|
|
||||||
IsoFile::IsoFile(SectorSource& reader, const wxString& filename)
|
IsoFile::IsoFile(SectorSource& reader, const std::string_view& filename)
|
||||||
: internalReader(reader)
|
: internalReader(reader)
|
||||||
, fileEntry(IsoDirectory(reader).FindFile(filename))
|
, fileEntry(IsoDirectory(reader).FindFile(filename))
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
IsoFile::IsoFile(const IsoDirectory& dir, const wxString& filename)
|
IsoFile::IsoFile(const IsoDirectory& dir, const std::string_view& filename)
|
||||||
: internalReader(dir.GetReader())
|
: internalReader(dir.GetReader())
|
||||||
, fileEntry(dir.FindFile(filename))
|
, fileEntry(dir.FindFile(filename))
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
#include "IsoFileDescriptor.h"
|
#include "IsoFileDescriptor.h"
|
||||||
#include "SectorSource.h"
|
#include "SectorSource.h"
|
||||||
|
|
||||||
|
#include "common/Pcsx2Defs.h"
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
class IsoFile
|
class IsoFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -35,8 +38,8 @@ protected:
|
||||||
int sectorOffset;
|
int sectorOffset;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IsoFile(const IsoDirectory& dir, const wxString& filename);
|
IsoFile(const IsoDirectory& dir, const std::string_view& filename);
|
||||||
IsoFile(SectorSource& reader, const wxString& filename);
|
IsoFile(SectorSource& reader, const std::string_view& filename);
|
||||||
IsoFile(SectorSource& reader, const IsoFileDescriptor& fileEntry);
|
IsoFile(SectorSource& reader, const IsoFileDescriptor& fileEntry);
|
||||||
virtual ~IsoFile() = default;
|
virtual ~IsoFile() = default;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/Pcsx2Defs.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
struct IsoFileDescriptor
|
struct IsoFileDescriptor
|
||||||
{
|
{
|
||||||
struct FileDate // not 1:1 with iso9660 date struct
|
struct FileDate // not 1:1 with iso9660 date struct
|
||||||
|
@ -32,7 +35,7 @@ struct IsoFileDescriptor
|
||||||
u32 lba;
|
u32 lba;
|
||||||
u32 size;
|
u32 size;
|
||||||
int flags;
|
int flags;
|
||||||
wxString name;
|
std::string name;
|
||||||
|
|
||||||
IsoFileDescriptor();
|
IsoFileDescriptor();
|
||||||
IsoFileDescriptor(const u8* data, int length);
|
IsoFileDescriptor(const u8* data, int length);
|
||||||
|
|
|
@ -21,16 +21,6 @@
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
void pxStream_OpenCheck(std::FILE* stream, const std::string& fname, const wxString& mode)
|
|
||||||
{
|
|
||||||
if (stream)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ScopedExcept ex(Exception::FromErrno(StringUtil::UTF8StringToWxString(fname), errno));
|
|
||||||
ex->SetDiagMsg(pxsFmt(L"Unable to open the file for %s: %s", WX_STR(mode), WX_STR(ex->DiagMsg())));
|
|
||||||
ex->Rethrow();
|
|
||||||
}
|
|
||||||
|
|
||||||
OutputIsoFile::OutputIsoFile()
|
OutputIsoFile::OutputIsoFile()
|
||||||
{
|
{
|
||||||
_init();
|
_init();
|
||||||
|
@ -62,7 +52,12 @@ void OutputIsoFile::Create(std::string filename, int version)
|
||||||
m_blocksize = 2048;
|
m_blocksize = 2048;
|
||||||
|
|
||||||
m_outstream = FileSystem::OpenCFile(m_filename.c_str(), "wb");
|
m_outstream = FileSystem::OpenCFile(m_filename.c_str(), "wb");
|
||||||
pxStream_OpenCheck(m_outstream, m_filename, L"writing");
|
if (!m_outstream)
|
||||||
|
{
|
||||||
|
Console.Error("(OutputIsoFile::Create) Unable to open the file '%s' for writing: %d", m_filename.c_str(), errno);
|
||||||
|
ScopedExcept ex(Exception::FromErrno(StringUtil::UTF8StringToWxString(filename), errno));
|
||||||
|
ex->Rethrow();
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLn("isoFile create ok: %s ", m_filename.c_str());
|
Console.WriteLn("isoFile create ok: %s ", m_filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,28 +29,24 @@
|
||||||
u32 ElfCRC;
|
u32 ElfCRC;
|
||||||
u32 ElfEntry;
|
u32 ElfEntry;
|
||||||
std::pair<u32,u32> ElfTextRange;
|
std::pair<u32,u32> ElfTextRange;
|
||||||
wxString LastELF;
|
std::string LastELF;
|
||||||
bool isPSXElf;
|
bool isPSXElf;
|
||||||
|
|
||||||
// All of ElfObjects functions.
|
// All of ElfObjects functions.
|
||||||
ElfObject::ElfObject(const wxString& srcfile, IsoFile& isofile, bool isPSXElf)
|
ElfObject::ElfObject(std::string srcfile, IsoFile& isofile, bool isPSXElf)
|
||||||
: data( wxULongLong(isofile.getLength()).GetLo(), L"ELF headers" )
|
: data(isofile.getLength(), L"ELF headers")
|
||||||
, proghead( NULL )
|
, filename(std::move(srcfile))
|
||||||
, secthead( NULL )
|
, header(*(ELF_HEADER*)data.GetPtr())
|
||||||
, filename( srcfile )
|
|
||||||
, header( *(ELF_HEADER*)data.GetPtr() )
|
|
||||||
{
|
{
|
||||||
checkElfSize(data.GetSizeInBytes());
|
checkElfSize(data.GetSizeInBytes());
|
||||||
readIso(isofile);
|
readIso(isofile);
|
||||||
initElfHeaders(isPSXElf);
|
initElfHeaders(isPSXElf);
|
||||||
}
|
}
|
||||||
|
|
||||||
ElfObject::ElfObject( const wxString& srcfile, uint hdrsize, bool isPSXElf )
|
ElfObject::ElfObject(std::string srcfile, u32 hdrsize, bool isPSXElf)
|
||||||
: data( wxULongLong(hdrsize).GetLo(), L"ELF headers" )
|
: data(hdrsize, L"ELF headers")
|
||||||
, proghead( NULL )
|
, filename(std::move(srcfile))
|
||||||
, secthead( NULL )
|
, header(*(ELF_HEADER*)data.GetPtr())
|
||||||
, filename( srcfile )
|
|
||||||
, header( *(ELF_HEADER*)data.GetPtr() )
|
|
||||||
{
|
{
|
||||||
checkElfSize(data.GetSizeInBytes());
|
checkElfSize(data.GetSizeInBytes());
|
||||||
readFile();
|
readFile();
|
||||||
|
@ -151,20 +147,20 @@ std::pair<u32,u32> ElfObject::getTextRange()
|
||||||
void ElfObject::readIso(IsoFile& file)
|
void ElfObject::readIso(IsoFile& file)
|
||||||
{
|
{
|
||||||
int rsize = file.read(data.GetPtr(), data.GetSizeInBytes());
|
int rsize = file.read(data.GetPtr(), data.GetSizeInBytes());
|
||||||
if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream(filename);
|
if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream(StringUtil::UTF8StringToWxString(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElfObject::readFile()
|
void ElfObject::readFile()
|
||||||
{
|
{
|
||||||
int rsize = 0;
|
int rsize = 0;
|
||||||
FILE *f = FileSystem::OpenCFile( filename.ToUTF8(), "rb" );
|
FILE *f = FileSystem::OpenCFile( filename.c_str(), "rb");
|
||||||
if (f == NULL) throw Exception::FileNotFound( filename );
|
if (f == NULL) throw Exception::FileNotFound(StringUtil::UTF8StringToWxString(filename));
|
||||||
|
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
rsize = fread(data.GetPtr(), 1, data.GetSizeInBytes(), f);
|
rsize = fread(data.GetPtr(), 1, data.GetSizeInBytes(), f);
|
||||||
fclose( f );
|
fclose( f );
|
||||||
|
|
||||||
if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream(filename);
|
if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream(StringUtil::UTF8StringToWxString(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
static wxString GetMsg_InvalidELF()
|
static wxString GetMsg_InvalidELF()
|
||||||
|
@ -184,7 +180,7 @@ void ElfObject::checkElfSize(s64 elfsize)
|
||||||
else if (elfsize == 0) diagMsg = L"Unexpected end of ELF file.";
|
else if (elfsize == 0) diagMsg = L"Unexpected end of ELF file.";
|
||||||
|
|
||||||
if (diagMsg)
|
if (diagMsg)
|
||||||
throw Exception::BadStream(filename)
|
throw Exception::BadStream(StringUtil::UTF8StringToWxString(filename))
|
||||||
.SetDiagMsg(diagMsg)
|
.SetDiagMsg(diagMsg)
|
||||||
.SetUserMsg(GetMsg_InvalidELF());
|
.SetUserMsg(GetMsg_InvalidELF());
|
||||||
}
|
}
|
||||||
|
@ -320,7 +316,7 @@ int GetPS2ElfName( std::string& name )
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IsoFSCDVD isofs;
|
IsoFSCDVD isofs;
|
||||||
IsoFile file( isofs, L"SYSTEM.CNF;1");
|
IsoFile file( isofs, "SYSTEM.CNF;1");
|
||||||
|
|
||||||
int size = file.getLength();
|
int size = file.getLength();
|
||||||
if( size == 0 ) return 0;
|
if( size == 0 ) return 0;
|
||||||
|
|
|
@ -121,9 +121,9 @@ class ElfObject
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SafeArray<u8> data;
|
SafeArray<u8> data;
|
||||||
ELF_PHR* proghead;
|
ELF_PHR* proghead = nullptr;
|
||||||
ELF_SHR* secthead;
|
ELF_SHR* secthead = nullptr;
|
||||||
wxString filename;
|
std::string filename;
|
||||||
|
|
||||||
void initElfHeaders(bool isPSXElf);
|
void initElfHeaders(bool isPSXElf);
|
||||||
void readIso(IsoFile& file);
|
void readIso(IsoFile& file);
|
||||||
|
@ -137,8 +137,8 @@ class ElfObject
|
||||||
// C++ does all the cleanup automagically for us.
|
// C++ does all the cleanup automagically for us.
|
||||||
virtual ~ElfObject() = default;
|
virtual ~ElfObject() = default;
|
||||||
|
|
||||||
ElfObject(const wxString& srcfile, IsoFile& isofile, bool isPSXElf);
|
ElfObject(std::string srcfile, IsoFile& isofile, bool isPSXElf);
|
||||||
ElfObject( const wxString& srcfile, uint hdrsize, bool isPSXElf );
|
ElfObject(std::string srcfile, u32 hdrsize, bool isPSXElf);
|
||||||
|
|
||||||
void loadProgramHeaders();
|
void loadProgramHeaders();
|
||||||
void loadSectionHeaders();
|
void loadSectionHeaders();
|
||||||
|
@ -153,14 +153,14 @@ class ElfObject
|
||||||
};
|
};
|
||||||
|
|
||||||
//-------------------
|
//-------------------
|
||||||
extern void loadElfFile(const wxString& filename);
|
extern void loadElfFile(const std::string& filename);
|
||||||
extern int GetPS2ElfName( std::string& dest );
|
extern int GetPS2ElfName( std::string& dest );
|
||||||
|
|
||||||
|
|
||||||
extern u32 ElfCRC;
|
extern u32 ElfCRC;
|
||||||
extern u32 ElfEntry;
|
extern u32 ElfEntry;
|
||||||
extern std::pair<u32,u32> ElfTextRange;
|
extern std::pair<u32,u32> ElfTextRange;
|
||||||
extern wxString LastELF;
|
extern std::string LastELF;
|
||||||
extern bool isPSXElf;
|
extern bool isPSXElf;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -149,7 +149,7 @@ bool GameList::GetElfListEntry(const std::string& path, GameList::Entry* entry)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ElfObject eo(StringUtil::UTF8StringToWxString(path), static_cast<uint>(file_size), false);
|
ElfObject eo(path, static_cast<uint>(file_size), false);
|
||||||
entry->crc = eo.getCRC();
|
entry->crc = eo.getCRC();
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
|
@ -203,10 +203,10 @@ bool GameList::GetGameListEntry(const std::string& path, GameList::Entry* entry)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cdvdReloadElfInfo(wxEmptyString);
|
cdvdReloadElfInfo();
|
||||||
|
|
||||||
entry->path = path;
|
entry->path = path;
|
||||||
entry->serial = StringUtil::wxStringToUTF8String(DiscSerial);
|
entry->serial = DiscSerial;
|
||||||
entry->crc = ElfCRC;
|
entry->crc = ElfCRC;
|
||||||
entry->total_size = sd.Size;
|
entry->total_size = sd.Size;
|
||||||
entry->compatibility_rating = CompatibilityRating::Unknown;
|
entry->compatibility_rating = CompatibilityRating::Unknown;
|
||||||
|
|
|
@ -114,7 +114,7 @@ void cpuReset()
|
||||||
AllowParams2 = !g_SkipBiosHack;
|
AllowParams2 = !g_SkipBiosHack;
|
||||||
|
|
||||||
ElfCRC = 0;
|
ElfCRC = 0;
|
||||||
DiscSerial = L"";
|
DiscSerial.clear();
|
||||||
ElfEntry = -1;
|
ElfEntry = -1;
|
||||||
|
|
||||||
// Probably not the right place, but it has to be done when the ram is actually initialized
|
// Probably not the right place, but it has to be done when the ram is actually initialized
|
||||||
|
@ -125,7 +125,7 @@ void cpuReset()
|
||||||
// the same (identical ELF names) but is actually different (devs actually could
|
// the same (identical ELF names) but is actually different (devs actually could
|
||||||
// run into this while testing minor binary hacked changes to ISO images, which
|
// run into this while testing minor binary hacked changes to ISO images, which
|
||||||
// is why I found out about this) --air
|
// is why I found out about this) --air
|
||||||
LastELF = L"";
|
LastELF.clear();
|
||||||
|
|
||||||
g_eeloadMain = 0, g_eeloadExec = 0, g_osdsys_str = 0;
|
g_eeloadMain = 0, g_eeloadExec = 0, g_osdsys_str = 0;
|
||||||
}
|
}
|
||||||
|
@ -620,13 +620,13 @@ int ParseArgumentString(u32 arg_block)
|
||||||
void __fastcall eeloadHook()
|
void __fastcall eeloadHook()
|
||||||
{
|
{
|
||||||
#ifndef PCSX2_CORE
|
#ifndef PCSX2_CORE
|
||||||
const wxString &elf_override = GetCoreThread().GetElfOverride();
|
const std::string elf_override(StringUtil::wxStringToUTF8String(GetCoreThread().GetElfOverride()));
|
||||||
#else
|
#else
|
||||||
const wxString elf_override(StringUtil::UTF8StringToWxString(VMManager::Internal::GetElfOverride()));
|
const std::string& elf_override(VMManager::Internal::GetElfOverride());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!elf_override.IsEmpty())
|
if (!elf_override.empty())
|
||||||
cdvdReloadElfInfo(L"host:" + elf_override);
|
cdvdReloadElfInfo(StringUtil::StdStringFromFormat("host:%s", elf_override.c_str()));
|
||||||
else
|
else
|
||||||
cdvdReloadElfInfo();
|
cdvdReloadElfInfo();
|
||||||
|
|
||||||
|
@ -702,10 +702,9 @@ void __fastcall eeloadHook()
|
||||||
if (g_SkipBiosHack && elfname.empty())
|
if (g_SkipBiosHack && elfname.empty())
|
||||||
{
|
{
|
||||||
std::string elftoload;
|
std::string elftoload;
|
||||||
if (!elf_override.IsEmpty())
|
if (!elf_override.empty())
|
||||||
{
|
{
|
||||||
elftoload = "host:";
|
elftoload = StringUtil::StdStringFromFormat("host:%s", elf_override.c_str());
|
||||||
elftoload += elf_override.ToUTF8();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -454,7 +454,7 @@ void InputRecording::GoToFirstFrame(wxWindow* parent)
|
||||||
wxString InputRecording::resolveGameName()
|
wxString InputRecording::resolveGameName()
|
||||||
{
|
{
|
||||||
std::string gameName;
|
std::string gameName;
|
||||||
const std::string gameKey(StringUtil::wxStringToUTF8String(SysGetDiscID()));
|
const std::string gameKey(SysGetDiscID());
|
||||||
if (!gameKey.empty())
|
if (!gameKey.empty())
|
||||||
{
|
{
|
||||||
auto game = GameDatabase::findGame(gameKey);
|
auto game = GameDatabase::findGame(gameKey);
|
||||||
|
|
|
@ -83,29 +83,22 @@ static void PostLoadPrep()
|
||||||
// SaveStateBase (implementations)
|
// SaveStateBase (implementations)
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
#ifndef PCSX2_CORE
|
#ifndef PCSX2_CORE
|
||||||
wxString SaveStateBase::GetSavestateFolder( int slot, bool isSavingOrLoading )
|
std::string SaveStateBase::GetSavestateFolder(int slot, bool isSavingOrLoading)
|
||||||
{
|
{
|
||||||
wxString CRCvalue = wxString::Format(wxT("%08X"), ElfCRC);
|
std::string CRCvalue(StringUtil::StdStringFromFormat("%08X", ElfCRC));
|
||||||
wxString serialName(DiscSerial);
|
std::string serialName;
|
||||||
|
|
||||||
if (g_GameStarted || g_GameLoading)
|
if (g_GameStarted || g_GameLoading)
|
||||||
{
|
{
|
||||||
if (DiscSerial.IsEmpty())
|
if (DiscSerial.empty())
|
||||||
{
|
|
||||||
std::string ElfString = LastELF.ToStdString();
|
|
||||||
std::string ElfString_delimiter = "/";
|
|
||||||
|
|
||||||
#ifndef _UNIX_
|
|
||||||
std::replace(ElfString.begin(), ElfString.end(), '\\', '/');
|
|
||||||
#endif
|
|
||||||
size_t pos = 0;
|
|
||||||
while ((pos = ElfString.find(ElfString_delimiter)) != std::string::npos)
|
|
||||||
{
|
{
|
||||||
// Running homebrew/standalone ELF, return only the ELF name.
|
// Running homebrew/standalone ELF, return only the ELF name.
|
||||||
ElfString.erase(0, pos + ElfString_delimiter.length());
|
// can't use FileSystem here because it's DOS paths
|
||||||
}
|
const std::string::size_type pos = std::min(DiscSerial.rfind('/'), DiscSerial.rfind('\\'));
|
||||||
wxString ElfString_toWxString(ElfString.c_str(), wxConvUTF8);
|
if (pos != std::string::npos)
|
||||||
serialName = ElfString_toWxString;
|
serialName = DiscSerial.substr(pos + 1);
|
||||||
|
else
|
||||||
|
serialName = DiscSerial;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -117,22 +110,24 @@ wxString SaveStateBase::GetSavestateFolder( int slot, bool isSavingOrLoading )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Still inside the BIOS/not running a game (why would anyone want to do this?)
|
// Still inside the BIOS/not running a game (why would anyone want to do this?)
|
||||||
const std::string biosString(StringUtil::StdStringFromFormat("BIOS (%s v%u.%u)", BiosZone.c_str(), (BiosVersion >> 8), BiosVersion & 0xff));
|
serialName = StringUtil::StdStringFromFormat("BIOS (%s v%u.%u)", BiosZone.c_str(), (BiosVersion >> 8), BiosVersion & 0xff);
|
||||||
serialName = StringUtil::UTF8StringToWxString(biosString);
|
CRCvalue = "None";
|
||||||
CRCvalue = L"None";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFileName dirname = wxFileName::DirName(g_Conf->FullpathToSaveState(serialName, CRCvalue));
|
const std::string dir(StringUtil::StdStringFromFormat("%s" FS_OSPATH_SEPARATOR_STR "%s - (%s)",
|
||||||
|
g_Conf->Folders.Savestates.ToUTF8().data(), serialName.c_str(), CRCvalue.c_str()));
|
||||||
|
|
||||||
if (isSavingOrLoading)
|
if (isSavingOrLoading)
|
||||||
{
|
{
|
||||||
if (!wxDirExists(g_Conf->FullpathToSaveState(serialName, CRCvalue)))
|
if (!FileSystem::DirectoryExists(dir.c_str()))
|
||||||
{
|
{
|
||||||
wxMkdir(g_Conf->FullpathToSaveState(serialName, CRCvalue));
|
// sstates should exist, no need to create it
|
||||||
|
FileSystem::CreateDirectoryPath(dir.c_str(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (dirname.GetPath() + "/" +
|
|
||||||
pxsFmt( L"%s (%s).%02d.p2s", WX_STR(serialName), WX_STR(CRCvalue), slot ));
|
return Path::CombineStdString(dir, StringUtil::StdStringFromFormat("%s (%s).%02d.p2s",
|
||||||
|
serialName.c_str(), CRCvalue.c_str(), slot));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -234,10 +229,10 @@ SaveStateBase& SaveStateBase::FreezeInternals()
|
||||||
Freeze(ElfCRC);
|
Freeze(ElfCRC);
|
||||||
|
|
||||||
char localDiscSerial[256];
|
char localDiscSerial[256];
|
||||||
StringUtil::Strlcpy(localDiscSerial, DiscSerial.ToUTF8(), sizeof(localDiscSerial));
|
StringUtil::Strlcpy(localDiscSerial, DiscSerial.c_str(), sizeof(localDiscSerial));
|
||||||
Freeze(localDiscSerial);
|
Freeze(localDiscSerial);
|
||||||
if (IsLoading())
|
if (IsLoading())
|
||||||
DiscSerial = wxString::FromUTF8(localDiscSerial);
|
DiscSerial = localDiscSerial;
|
||||||
|
|
||||||
// Third Block - Cycle Timers and Events
|
// Third Block - Cycle Timers and Events
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
virtual ~SaveStateBase() { }
|
virtual ~SaveStateBase() { }
|
||||||
|
|
||||||
#ifndef PCSX2_CORE
|
#ifndef PCSX2_CORE
|
||||||
static wxString GetSavestateFolder( int slot, bool isSavingOrLoading = false );
|
static std::string GetSavestateFolder(int slot, bool isSavingOrLoading = false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Gets the version of savestate that this object is acting on.
|
// Gets the version of savestate that this object is acting on.
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include "common/MemsetFast.inl"
|
#include "common/MemsetFast.inl"
|
||||||
#include "common/Perf.h"
|
#include "common/Perf.h"
|
||||||
|
#include "common/StringUtil.h"
|
||||||
#include "CDVD/CDVD.h"
|
#include "CDVD/CDVD.h"
|
||||||
|
|
||||||
#ifdef PCSX2_CORE
|
#ifdef PCSX2_CORE
|
||||||
|
@ -646,21 +647,21 @@ u8* SysMmapEx(uptr base, u32 size, uptr bounds, const char *caller)
|
||||||
return Mem;
|
return Mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString SysGetBiosDiscID()
|
std::string SysGetBiosDiscID()
|
||||||
{
|
{
|
||||||
// FIXME: we should return a serial based on
|
// FIXME: we should return a serial based on
|
||||||
// the BIOS being run (either a checksum of the BIOS roms, and/or a string based on BIOS
|
// the BIOS being run (either a checksum of the BIOS roms, and/or a string based on BIOS
|
||||||
// region and revision).
|
// region and revision).
|
||||||
|
|
||||||
return wxEmptyString;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function always returns a valid DiscID -- using the Sony serial when possible, and
|
// This function always returns a valid DiscID -- using the Sony serial when possible, and
|
||||||
// falling back on the CRC checksum of the ELF binary if the PS2 software being run is
|
// falling back on the CRC checksum of the ELF binary if the PS2 software being run is
|
||||||
// homebrew or some other serial-less item.
|
// homebrew or some other serial-less item.
|
||||||
wxString SysGetDiscID()
|
std::string SysGetDiscID()
|
||||||
{
|
{
|
||||||
if( !DiscSerial.IsEmpty() ) return DiscSerial;
|
if( !DiscSerial.empty() ) return DiscSerial;
|
||||||
|
|
||||||
if( !ElfCRC )
|
if( !ElfCRC )
|
||||||
{
|
{
|
||||||
|
@ -668,5 +669,5 @@ wxString SysGetDiscID()
|
||||||
return SysGetBiosDiscID();
|
return SysGetBiosDiscID();
|
||||||
}
|
}
|
||||||
|
|
||||||
return pxsFmt( L"%08x", ElfCRC );
|
return StringUtil::StdStringFromFormat("%08x", ElfCRC);
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,8 +165,8 @@ extern u8 *SysMmapEx(uptr base, u32 size, uptr bounds, const char *caller="Unnam
|
||||||
extern void vSyncDebugStuff( uint frame );
|
extern void vSyncDebugStuff( uint frame );
|
||||||
extern void NTFS_CompressFile( const wxString& file, bool compressStatus=true );
|
extern void NTFS_CompressFile( const wxString& file, bool compressStatus=true );
|
||||||
|
|
||||||
extern wxString SysGetBiosDiscID();
|
extern std::string SysGetBiosDiscID();
|
||||||
extern wxString SysGetDiscID();
|
extern std::string SysGetDiscID();
|
||||||
|
|
||||||
extern SysMainMemory& GetVmMemory();
|
extern SysMainMemory& GetVmMemory();
|
||||||
|
|
||||||
|
|
|
@ -412,7 +412,7 @@ void VMManager::UpdateRunningGame(bool force)
|
||||||
{
|
{
|
||||||
const bool ingame = (ElfCRC && (g_GameLoading || g_GameStarted));
|
const bool ingame = (ElfCRC && (g_GameLoading || g_GameStarted));
|
||||||
new_crc = ingame ? ElfCRC : 0;
|
new_crc = ingame ? ElfCRC : 0;
|
||||||
new_serial = ingame ? SysGetDiscID().ToStdString() : SysGetBiosDiscID().ToStdString();
|
new_serial = ingame ? SysGetDiscID() : SysGetBiosDiscID();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -545,12 +545,6 @@ void AppConfig::FolderOptions::Set(FoldersEnum_t folderidx, const wxString& src,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString AppConfig::FullpathToSaveState(wxString serialName, wxString CRCvalue) const
|
|
||||||
{
|
|
||||||
wxString Sstate_append = serialName + " - " + "(" + CRCvalue + ")";
|
|
||||||
return Path::Combine(Folders.Savestates, Sstate_append);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsPortable()
|
bool IsPortable()
|
||||||
{
|
{
|
||||||
return InstallationMode == InstallMode_Portable;
|
return InstallationMode == InstallMode_Portable;
|
||||||
|
|
|
@ -299,7 +299,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AppConfig();
|
AppConfig();
|
||||||
wxString FullpathToSaveState(wxString serialName, wxString CRCvalue) const;
|
std::string FullpathToSaveState(const std::string& serialName, const std::string& CRCvalue) const;
|
||||||
void LoadSave(IniInterface& ini, SettingsWrapper& wrap);
|
void LoadSave(IniInterface& ini, SettingsWrapper& wrap);
|
||||||
void LoadSaveRootItems(IniInterface& ini);
|
void LoadSaveRootItems(IniInterface& ini);
|
||||||
|
|
||||||
|
|
|
@ -368,10 +368,10 @@ static void _ApplySettings(const Pcsx2Config& src, Pcsx2Config& fixup)
|
||||||
else
|
else
|
||||||
GameInfo::gameCRC = L""; // Needs to be reset when rebooting otherwise previously loaded patches may load
|
GameInfo::gameCRC = L""; // Needs to be reset when rebooting otherwise previously loaded patches may load
|
||||||
|
|
||||||
if (ingame && !DiscSerial.IsEmpty())
|
if (ingame && !DiscSerial.empty())
|
||||||
GameInfo::gameSerial = DiscSerial;
|
GameInfo::gameSerial = StringUtil::UTF8StringToWxString(DiscSerial);
|
||||||
|
|
||||||
const wxString newGameKey(ingame ? SysGetDiscID() : SysGetBiosDiscID());
|
const wxString newGameKey(StringUtil::UTF8StringToWxString(ingame ? SysGetDiscID() : SysGetBiosDiscID()));
|
||||||
const bool verbose(newGameKey != curGameKey && ingame);
|
const bool verbose(newGameKey != curGameKey && ingame);
|
||||||
//Console.WriteLn(L"------> patches verbose: %d prev: '%s' new: '%s'", (int)verbose, WX_STR(curGameKey), WX_STR(newGameKey));
|
//Console.WriteLn(L"------> patches verbose: %d prev: '%s' new: '%s'", (int)verbose, WX_STR(curGameKey), WX_STR(newGameKey));
|
||||||
SetupPatchesCon(verbose);
|
SetupPatchesCon(verbose);
|
||||||
|
@ -405,7 +405,7 @@ static void _ApplySettings(const Pcsx2Config& src, Pcsx2Config& fixup)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Set correct title for loading standalone/homebrew ELFs
|
// Set correct title for loading standalone/homebrew ELFs
|
||||||
GameInfo::gameName = LastELF.AfterLast('\\');
|
GameInfo::gameName = StringUtil::UTF8StringToWxString(LastELF).AfterLast('\\');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ void States_DefrostCurrentSlotBackup()
|
||||||
|
|
||||||
void States_updateLoadBackupMenuItem()
|
void States_updateLoadBackupMenuItem()
|
||||||
{
|
{
|
||||||
wxString file(SaveStateBase::GetSavestateFolder(StatesC) + ".backup");
|
wxString file(StringUtil::UTF8StringToWxString(SaveStateBase::GetSavestateFolder(StatesC) + ".backup"));
|
||||||
|
|
||||||
sMainFrame.EnableMenuItem(MenuId_State_LoadBackup, wxFileExists(file));
|
sMainFrame.EnableMenuItem(MenuId_State_LoadBackup, wxFileExists(file));
|
||||||
sMainFrame.SetMenuItemLabel(MenuId_State_LoadBackup, wxsFormat(L"%s %d", _("Backup"), StatesC));
|
sMainFrame.SetMenuItemLabel(MenuId_State_LoadBackup, wxsFormat(L"%s %d", _("Backup"), StatesC));
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
#include "Elfheader.h"
|
#include "Elfheader.h"
|
||||||
#include "App.h"
|
#include "App.h"
|
||||||
|
#include "common/StringUtil.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
// Uncomment to turn on the new saveslot UI.
|
// Uncomment to turn on the new saveslot UI.
|
||||||
|
@ -37,7 +38,7 @@
|
||||||
//#define SAVESLOT_LOGS
|
//#define SAVESLOT_LOGS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern wxString DiscSerial;
|
extern std::string DiscSerial;
|
||||||
static const int StateSlotsCount = 10;
|
static const int StateSlotsCount = 10;
|
||||||
|
|
||||||
class Saveslot
|
class Saveslot
|
||||||
|
@ -68,14 +69,14 @@ public:
|
||||||
|
|
||||||
bool isUsed()
|
bool isUsed()
|
||||||
{
|
{
|
||||||
return wxFileExists(SaveStateBase::GetSavestateFolder(slot_num, false));
|
return wxFileExists(StringUtil::UTF8StringToWxString(SaveStateBase::GetSavestateFolder(slot_num, false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDateTime GetTimestamp()
|
wxDateTime GetTimestamp()
|
||||||
{
|
{
|
||||||
if (!isUsed()) return wxInvalidDateTime;
|
if (!isUsed()) return wxInvalidDateTime;
|
||||||
|
|
||||||
return wxDateTime(wxFileModificationTime(SaveStateBase::GetSavestateFolder(slot_num, false)));
|
return wxDateTime(wxFileModificationTime(StringUtil::UTF8StringToWxString(SaveStateBase::GetSavestateFolder(slot_num, false))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateCache()
|
void UpdateCache()
|
||||||
|
@ -83,7 +84,7 @@ public:
|
||||||
empty = !isUsed();
|
empty = !isUsed();
|
||||||
updated = GetTimestamp();
|
updated = GetTimestamp();
|
||||||
crc = ElfCRC;
|
crc = ElfCRC;
|
||||||
serialName = DiscSerial;
|
serialName = StringUtil::UTF8StringToWxString(DiscSerial);
|
||||||
invalid_cache = false;
|
invalid_cache = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,12 +122,12 @@ void StateCopy_LoadFromFile(const wxString& file)
|
||||||
// the one in the memory save. :)
|
// the one in the memory save. :)
|
||||||
void StateCopy_SaveToSlot(uint num)
|
void StateCopy_SaveToSlot(uint num)
|
||||||
{
|
{
|
||||||
const wxString file(SaveStateBase::GetSavestateFolder(num, true));
|
const wxString file(StringUtil::UTF8StringToWxString(SaveStateBase::GetSavestateFolder(num, true)));
|
||||||
|
|
||||||
// Backup old Savestate if one exists.
|
// Backup old Savestate if one exists.
|
||||||
if (wxFileExists(file) && EmuConfig.BackupSavestate)
|
if (wxFileExists(file) && EmuConfig.BackupSavestate)
|
||||||
{
|
{
|
||||||
const wxString copy(SaveStateBase::GetSavestateFolder(num, true) + pxsFmt(L".backup"));
|
const wxString copy(StringUtil::UTF8StringToWxString(SaveStateBase::GetSavestateFolder(num, true)) + pxsFmt(L".backup"));
|
||||||
|
|
||||||
Console.Indent().WriteLn(Color_StrongGreen, L"Backing up existing state in slot %d.", num);
|
Console.Indent().WriteLn(Color_StrongGreen, L"Backing up existing state in slot %d.", num);
|
||||||
wxRenameFile(file, copy);
|
wxRenameFile(file, copy);
|
||||||
|
@ -144,7 +144,7 @@ void StateCopy_SaveToSlot(uint num)
|
||||||
|
|
||||||
void StateCopy_LoadFromSlot(uint slot, bool isFromBackup)
|
void StateCopy_LoadFromSlot(uint slot, bool isFromBackup)
|
||||||
{
|
{
|
||||||
wxString file(SaveStateBase::GetSavestateFolder(slot, true) + wxString(isFromBackup ? L".backup" : L""));
|
wxString file(StringUtil::UTF8StringToWxString(SaveStateBase::GetSavestateFolder(slot, true)) + wxString(isFromBackup ? L".backup" : L""));
|
||||||
|
|
||||||
if (!wxFileExists(file))
|
if (!wxFileExists(file))
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,7 @@ static void _SaveLoadStuff(bool enabled)
|
||||||
sMainFrame.EnableMenuItem(MenuId_Sys_SaveStates, enabled);
|
sMainFrame.EnableMenuItem(MenuId_Sys_SaveStates, enabled);
|
||||||
|
|
||||||
#ifdef USE_NEW_SAVESLOTS_UI
|
#ifdef USE_NEW_SAVESLOTS_UI
|
||||||
|
const wxString wxDiscSerial(StringUtil::UTF8StringToWxString(DiscSerial));
|
||||||
bool crcChanged = false;
|
bool crcChanged = false;
|
||||||
// Run though all the slots. Update if they need updating or the crc changed.
|
// Run though all the slots. Update if they need updating or the crc changed.
|
||||||
for (Saveslot &slot : saveslot_cache)
|
for (Saveslot &slot : saveslot_cache)
|
||||||
|
@ -62,7 +63,7 @@ static void _SaveLoadStuff(bool enabled)
|
||||||
|
|
||||||
// We need to reload the file information if the crc or serial # changed.
|
// We need to reload the file information if the crc or serial # changed.
|
||||||
// Invalidate slot cache when using full boot (g_GameLoading) otherwise it won't see the new folder path
|
// Invalidate slot cache when using full boot (g_GameLoading) otherwise it won't see the new folder path
|
||||||
if ((g_GameLoading || slot.crc != ElfCRC) || (slot.serialName != DiscSerial))
|
if ((g_GameLoading || slot.crc != ElfCRC) || (slot.serialName != wxDiscSerial))
|
||||||
{
|
{
|
||||||
slot.invalid_cache = true;
|
slot.invalid_cache = true;
|
||||||
crcChanged = true;
|
crcChanged = true;
|
||||||
|
|
Loading…
Reference in New Issue