From f4aa5e1b9802b2a81a0ff7f5ebe04bb38d1f98f7 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 15 Feb 2025 11:35:46 +1000 Subject: [PATCH] MemoryCard: Filename -> Path --- src/core/memory_card.cpp | 26 +++++++++++++------------- src/core/memory_card.h | 8 ++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/core/memory_card.cpp b/src/core/memory_card.cpp index db8c52960..314472d79 100644 --- a/src/core/memory_card.cpp +++ b/src/core/memory_card.cpp @@ -293,27 +293,27 @@ std::unique_ptr MemoryCard::Create() return mc; } -std::unique_ptr MemoryCard::Open(std::string_view filename) +std::unique_ptr MemoryCard::Open(std::string_view path) { std::unique_ptr mc = std::make_unique(); - mc->m_filename = filename; + mc->m_path = path; Error error; - if (!FileSystem::FileExists(mc->m_filename.c_str())) [[unlikely]] + if (!FileSystem::FileExists(mc->m_path.c_str())) [[unlikely]] { mc->Format(); mc->m_changed = false; } - else if (!MemoryCardImage::LoadFromFile(&mc->m_data, mc->m_filename.c_str(), &error)) [[unlikely]] + else if (!MemoryCardImage::LoadFromFile(&mc->m_data, mc->m_path.c_str(), &error)) [[unlikely]] { Host::AddIconOSDMessage( - fmt::format("memory_card_{}", filename), ICON_FA_SD_CARD, + fmt::format("memory_card_{}", path), ICON_FA_SD_CARD, fmt::format(TRANSLATE_FS("MemoryCard", "{} could not be read:\n{}\nThe memory card will NOT be saved.\nYou must " "delete the memory card manually if you want to save."), - Path::GetFileName(filename), error.GetDescription()), + Path::GetFileName(path), error.GetDescription()), Host::OSD_CRITICAL_ERROR_DURATION); mc->Format(); - mc->m_filename = {}; + mc->m_path = {}; mc->m_changed = false; } @@ -335,21 +335,21 @@ bool MemoryCard::SaveIfChanged(bool display_osd_message) m_changed = false; - if (m_filename.empty()) + if (m_path.empty()) return false; std::string osd_key; std::string display_name; if (display_osd_message) { - osd_key = fmt::format("memory_card_save_{}", m_filename); - display_name = FileSystem::GetDisplayNameFromPath(m_filename); + osd_key = fmt::format("memory_card_save_{}", m_path); + display_name = FileSystem::GetDisplayNameFromPath(m_path); } - INFO_LOG("Saving memory card to {}...", Path::GetFileTitle(m_filename)); + INFO_LOG("Saving memory card to {}...", Path::GetFileTitle(m_path)); Error error; - if (!MemoryCardImage::SaveToFile(m_data, m_filename.c_str(), &error)) + if (!MemoryCardImage::SaveToFile(m_data, m_path.c_str(), &error)) { if (display_osd_message) { @@ -376,7 +376,7 @@ bool MemoryCard::SaveIfChanged(bool display_osd_message) void MemoryCard::QueueFileSave() { // skip if the event is already pending, or we don't have a backing file - if (m_save_event.IsActive() || m_filename.empty()) + if (m_save_event.IsActive() || m_path.empty()) return; // save in one second, that should be long enough for everything to finish writing diff --git a/src/core/memory_card.h b/src/core/memory_card.h index 63c376723..4dc705579 100644 --- a/src/core/memory_card.h +++ b/src/core/memory_card.h @@ -23,12 +23,12 @@ public: static constexpr u32 STATE_SIZE = 1 + 1 + 2 + 1 + 1 + 1 + MemoryCardImage::DATA_SIZE + 1; static std::unique_ptr Create(); - static std::unique_ptr Open(std::string_view filename); + static std::unique_ptr Open(std::string_view path); const MemoryCardImage::DataArray& GetData() const { return m_data; } MemoryCardImage::DataArray& GetData() { return m_data; } - const std::string& GetFilename() const { return m_filename; } - void SetFilename(std::string filename) { m_filename = std::move(filename); } + const std::string& GetFilename() const { return m_path; } + void SetFilename(std::string filename) { m_path = std::move(filename); } void Reset(); bool DoState(StateWrapper& sw); @@ -107,7 +107,7 @@ private: bool m_changed = false; TimingEvent m_save_event; - std::string m_filename; + std::string m_path; MemoryCardImage::DataArray m_data{}; };