diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index f5d14865d..b4b9747a4 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -474,7 +474,10 @@ void HostInterface::CreateUserDirectorySubdirectories() { bool result = true; + result &= FileSystem::CreateDirectory(GetUserDirectoryRelativePath("bios").c_str(), false); result &= FileSystem::CreateDirectory(GetUserDirectoryRelativePath("cache").c_str(), false); + result &= FileSystem::CreateDirectory(GetUserDirectoryRelativePath("savestates").c_str(), false); + result &= FileSystem::CreateDirectory(GetUserDirectoryRelativePath("memcards").c_str(), false); if (!result) ReportError("Failed to create one or more user directories. This may cause issues at runtime."); @@ -513,6 +516,32 @@ std::string HostInterface::GetGameListDatabaseFileName() const return GetUserDirectoryRelativePath("cache/redump.dat"); } +std::string HostInterface::GetGameSaveStateFileName(const char* game_code, s32 slot) +{ + if (slot < 0) + return GetUserDirectoryRelativePath("savestates/%s_resume.sav", game_code); + else + return GetUserDirectoryRelativePath("savestates/%s_%d.sav", game_code, slot); +} + +std::string HostInterface::GetGlobalSaveStateFileName(s32 slot) +{ + if (slot < 0) + return GetUserDirectoryRelativePath("savestates/resume.sav"); + else + return GetUserDirectoryRelativePath("savestates/savestate_%d.sav", slot); +} + +std::string HostInterface::GetSharedMemoryCardPath(u32 slot) +{ + return GetUserDirectoryRelativePath("memcards/shared_card_%d.mcd", slot + 1); +} + +std::string HostInterface::GetGameMemoryCardPath(const char* game_code, u32 slot) +{ + return GetUserDirectoryRelativePath("memcards/game_card_%s_%d.mcd", game_code, slot + 1); +} + void HostInterface::UpdateSettings(const std::function& apply_callback) { const GPURenderer old_gpu_renderer = m_settings.gpu_renderer; diff --git a/src/core/host_interface.h b/src/core/host_interface.h index 77f8ce736..b66ea6307 100644 --- a/src/core/host_interface.h +++ b/src/core/host_interface.h @@ -104,6 +104,18 @@ protected: /// Returns the path of the game database cache file. std::string GetGameListDatabaseFileName() const; + /// Returns the path to a save state file. Specifying an index of -1 is the "resume" save state. + std::string GetGameSaveStateFileName(const char* game_code, s32 slot); + + /// Returns the path to a save state file. Specifying an index of -1 is the "resume" save state. + std::string GetGlobalSaveStateFileName(s32 slot); + + /// Returns the default path to a memory card. + std::string GetSharedMemoryCardPath(u32 slot); + + /// Returns the default path to a memory card for a specific game. + std::string GetGameMemoryCardPath(const char* game_code, u32 slot); + /// Applies new settings, updating internal state as needed. apply_callback should call m_settings.Load() after /// locking any required mutexes. void UpdateSettings(const std::function& apply_callback);