diff --git a/Core/SaveStateManager.cpp b/Core/SaveStateManager.cpp index 5611cb7..5e9c386 100644 --- a/Core/SaveStateManager.cpp +++ b/Core/SaveStateManager.cpp @@ -27,18 +27,6 @@ string SaveStateManager::GetStateFilepath(int stateIndex) return FolderUtilities::CombinePath(folder, filename); } -uint64_t SaveStateManager::GetStateInfo(int stateIndex) -{ - string filepath = SaveStateManager::GetStateFilepath(stateIndex); - ifstream file(filepath, ios::in | ios::binary); - - if(file) { - file.close(); - return FolderUtilities::GetFileModificationTime(filepath); - } - return 0; -} - void SaveStateManager::SelectSaveSlot(int slotIndex) { _lastIndex = slotIndex; diff --git a/Core/SaveStateManager.h b/Core/SaveStateManager.h index 7f9da53..4eed02e 100644 --- a/Core/SaveStateManager.h +++ b/Core/SaveStateManager.h @@ -18,8 +18,6 @@ public: SaveStateManager(shared_ptr console); - uint64_t GetStateInfo(int stateIndex); - void SaveState(); bool LoadState(); diff --git a/InteropDLL/EmuApiWrapper.cpp b/InteropDLL/EmuApiWrapper.cpp index f00c088..0f7238d 100644 --- a/InteropDLL/EmuApiWrapper.cpp +++ b/InteropDLL/EmuApiWrapper.cpp @@ -249,7 +249,6 @@ extern "C" { DllExport void __stdcall LoadState(uint32_t stateIndex) { _console->GetSaveStateManager()->LoadState(stateIndex); } DllExport void __stdcall SaveStateFile(char* filepath) { _console->GetSaveStateManager()->SaveState(filepath); } DllExport void __stdcall LoadStateFile(char* filepath) { _console->GetSaveStateManager()->LoadState(filepath); } - DllExport int64_t __stdcall GetStateInfo(uint32_t stateIndex) { return _console->GetSaveStateManager()->GetStateInfo(stateIndex); } DllExport void __stdcall LoadRecentGame(char* filepath, bool resetGame) { _console->GetSaveStateManager()->LoadRecentGame(filepath, resetGame); } DllExport void __stdcall PgoRunTest(vector testRoms, bool enableDebugger) diff --git a/UI/Emulation/SaveStateManager.cs b/UI/Emulation/SaveStateManager.cs index 271c457..c7ac2a9 100644 --- a/UI/Emulation/SaveStateManager.cs +++ b/UI/Emulation/SaveStateManager.cs @@ -4,6 +4,7 @@ using Mesen.GUI.Forms; using Mesen.GUI.Properties; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -18,15 +19,15 @@ namespace Mesen.GUI.Emulation public static void UpdateStateMenu(ToolStripMenuItem menu, bool forSave) { for(uint i = 1; i <= NumberOfSaveSlots + (forSave ? 0 : 1); i++) { - Int64 fileTime = EmuApi.GetStateInfo(i); + string statePath = Path.Combine(ConfigManager.SaveStateFolder, EmuApi.GetRomInfo().GetRomName() + "_" + i + ".mss"); string label; bool isAutoSaveSlot = i == NumberOfSaveSlots + 1; string slotName = isAutoSaveSlot ? "Auto" : i.ToString(); - if(fileTime == 0) { + if(!File.Exists(statePath)) { label = slotName + ". " + ResourceHelper.GetMessage("EmptyState"); } else { - DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(fileTime).ToLocalTime(); + DateTime dateTime = new FileInfo(statePath).LastWriteTime; label = slotName + ". " + dateTime.ToShortDateString() + " " + dateTime.ToShortTimeString(); } diff --git a/UI/Interop/EmuApi.cs b/UI/Interop/EmuApi.cs index 49fac5e..ff29f84 100644 --- a/UI/Interop/EmuApi.cs +++ b/UI/Interop/EmuApi.cs @@ -85,7 +85,6 @@ namespace Mesen.GUI [DllImport(DllPath)] public static extern void LoadState(UInt32 stateIndex); [DllImport(DllPath)] public static extern void SaveStateFile([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string filepath); [DllImport(DllPath)] public static extern void LoadStateFile([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string filepath); - [DllImport(DllPath)] public static extern Int64 GetStateInfo(UInt32 stateIndex); [DllImport(DllPath)] public static extern void SetCheats([In]UInt32[] cheats, UInt32 cheatCount); [DllImport(DllPath)] public static extern void ClearCheats(); diff --git a/Utilities/FolderUtilities.cpp b/Utilities/FolderUtilities.cpp index 6175042..47a648c 100644 --- a/Utilities/FolderUtilities.cpp +++ b/Utilities/FolderUtilities.cpp @@ -224,11 +224,6 @@ string FolderUtilities::CombinePath(string folder, string filename) } } -int64_t FolderUtilities::GetFileModificationTime(string filepath) -{ - std::error_code errorCode; - return fs::last_write_time(fs::u8path(filepath), errorCode).time_since_epoch() / std::chrono::seconds(1); -} #else //Libretro: Avoid using filesystem API. @@ -277,8 +272,4 @@ string FolderUtilities::CombinePath(string folder, string filename) return folder + filename; } -int64_t FolderUtilities::GetFileModificationTime(string filepath) -{ - return 0; -} #endif \ No newline at end of file diff --git a/Utilities/FolderUtilities.h b/Utilities/FolderUtilities.h index a281104..447e7f0 100644 --- a/Utilities/FolderUtilities.h +++ b/Utilities/FolderUtilities.h @@ -38,7 +38,5 @@ public: static void CreateFolder(string folder); - static int64_t GetFileModificationTime(string filepath); - static string CombinePath(string folder, string filename); }; \ No newline at end of file