mirror of
https://github.com/libretro/Play-.git
synced 2024-11-28 03:00:49 +00:00
Use filesystem::path to represent state path.
This commit is contained in:
parent
6886f56c96
commit
288445257b
@ -10,6 +10,7 @@
|
||||
#include "Ps2Const.h"
|
||||
#include "iop/Iop_SifManPs2.h"
|
||||
#include "StdStream.h"
|
||||
#include "StdStreamUtils.h"
|
||||
#include "GZipStream.h"
|
||||
#include "MemoryStateFile.h"
|
||||
#include "zip/ZipArchiveWriter.h"
|
||||
@ -226,17 +227,17 @@ void CPS2VM::Destroy()
|
||||
DestroyVM();
|
||||
}
|
||||
|
||||
unsigned int CPS2VM::SaveState(const char* sPath)
|
||||
unsigned int CPS2VM::SaveState(const filesystem::path& statePath)
|
||||
{
|
||||
unsigned int result = 0;
|
||||
m_mailBox.SendCall(std::bind(&CPS2VM::SaveVMState, this, sPath, std::ref(result)), true);
|
||||
m_mailBox.SendCall(std::bind(&CPS2VM::SaveVMState, this, statePath, std::ref(result)), true);
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned int CPS2VM::LoadState(const char* sPath)
|
||||
unsigned int CPS2VM::LoadState(const filesystem::path& statePath)
|
||||
{
|
||||
unsigned int result = 0;
|
||||
m_mailBox.SendCall(std::bind(&CPS2VM::LoadVMState, this, sPath, std::ref(result)), true);
|
||||
m_mailBox.SendCall(std::bind(&CPS2VM::LoadVMState, this, statePath, std::ref(result)), true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -389,7 +390,7 @@ void CPS2VM::DestroyVM()
|
||||
CDROM0_Destroy();
|
||||
}
|
||||
|
||||
void CPS2VM::SaveVMState(const char* sPath, unsigned int& result)
|
||||
void CPS2VM::SaveVMState(const filesystem::path& statePath, unsigned int& result)
|
||||
{
|
||||
if(m_ee->m_gs == NULL)
|
||||
{
|
||||
@ -400,7 +401,7 @@ void CPS2VM::SaveVMState(const char* sPath, unsigned int& result)
|
||||
|
||||
try
|
||||
{
|
||||
Framework::CStdStream stateStream(sPath, "wb");
|
||||
auto stateStream = Framework::CreateOutputStdStream(statePath.native());
|
||||
Framework::CZipArchiveWriter archive;
|
||||
|
||||
m_ee->SaveState(archive);
|
||||
@ -415,12 +416,10 @@ void CPS2VM::SaveVMState(const char* sPath, unsigned int& result)
|
||||
return;
|
||||
}
|
||||
|
||||
printf("PS2VM: Saved state to file '%s'.\r\n", sPath);
|
||||
|
||||
result = 0;
|
||||
}
|
||||
|
||||
void CPS2VM::LoadVMState(const char* sPath, unsigned int& result)
|
||||
void CPS2VM::LoadVMState(const filesystem::path& statePath, unsigned int& result)
|
||||
{
|
||||
if(m_ee->m_gs == NULL)
|
||||
{
|
||||
@ -431,7 +430,7 @@ void CPS2VM::LoadVMState(const char* sPath, unsigned int& result)
|
||||
|
||||
try
|
||||
{
|
||||
Framework::CStdStream stateStream(sPath, "rb");
|
||||
auto stateStream = Framework::CreateInputStdStream(statePath.native());
|
||||
Framework::CZipArchiveReader archive(stateStream);
|
||||
|
||||
try
|
||||
@ -453,8 +452,6 @@ void CPS2VM::LoadVMState(const char* sPath, unsigned int& result)
|
||||
return;
|
||||
}
|
||||
|
||||
printf("PS2VM: Loaded state from file '%s'.\r\n", sPath);
|
||||
|
||||
OnMachineStateChange();
|
||||
|
||||
result = 0;
|
||||
|
@ -63,8 +63,8 @@ public:
|
||||
void CreateSoundHandler(const CSoundHandler::FactoryFunction&);
|
||||
void DestroySoundHandler();
|
||||
|
||||
unsigned int SaveState(const char*);
|
||||
unsigned int LoadState(const char*);
|
||||
unsigned int SaveState(const boost::filesystem::path&);
|
||||
unsigned int LoadState(const boost::filesystem::path&);
|
||||
|
||||
void TriggerFrameDump(const FrameDumpCallback&);
|
||||
|
||||
@ -91,8 +91,8 @@ private:
|
||||
void CreateVM();
|
||||
void ResetVM();
|
||||
void DestroyVM();
|
||||
void SaveVMState(const char*, unsigned int&);
|
||||
void LoadVMState(const char*, unsigned int&);
|
||||
void SaveVMState(const boost::filesystem::path&, unsigned int&);
|
||||
void LoadVMState(const boost::filesystem::path&, unsigned int&);
|
||||
|
||||
void ReloadExecutable(const char*, const CPS2OS::ArgumentList&);
|
||||
|
||||
|
@ -439,7 +439,8 @@ void CMainWindow::SaveState()
|
||||
if(m_virtualMachine.m_ee->m_os->GetELF() == nullptr) return;
|
||||
|
||||
Framework::PathUtils::EnsurePathExists(GetStateDirectoryPath());
|
||||
if(m_virtualMachine.SaveState(GenerateStatePath().string().c_str()) == 0)
|
||||
auto statePath = GenerateStatePath();
|
||||
if(m_virtualMachine.SaveState(statePath) == 0)
|
||||
{
|
||||
PrintStatusTextA("Saved state to slot %i.", m_stateSlot);
|
||||
}
|
||||
@ -453,7 +454,8 @@ void CMainWindow::LoadState()
|
||||
{
|
||||
if(m_virtualMachine.m_ee->m_os->GetELF() == nullptr) return;
|
||||
|
||||
if(m_virtualMachine.LoadState(GenerateStatePath().string().c_str()) == 0)
|
||||
auto statePath = GenerateStatePath();
|
||||
if(m_virtualMachine.LoadState(statePath) == 0)
|
||||
{
|
||||
PrintStatusTextA("Loaded state from slot %i.", m_stateSlot);
|
||||
}
|
||||
@ -891,7 +893,7 @@ boost::filesystem::path CMainWindow::GetStateDirectoryPath()
|
||||
|
||||
boost::filesystem::path CMainWindow::GenerateStatePath() const
|
||||
{
|
||||
std::string stateFileName = std::string(m_virtualMachine.m_ee->m_os->GetExecutableName()) + ".st" + std::to_string(m_stateSlot) + ".zip";
|
||||
auto stateFileName = string_format("%s.st%d.zip", m_virtualMachine.m_ee->m_os->GetExecutableName(), m_stateSlot);
|
||||
return GetStateDirectoryPath() / boost::filesystem::path(stateFileName);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user