diff --git a/src/core/memory_card.cpp b/src/core/memory_card.cpp index 61ebffec6..5cfc1c569 100644 --- a/src/core/memory_card.cpp +++ b/src/core/memory_card.cpp @@ -36,20 +36,6 @@ MemoryCard::~MemoryCard() SaveIfChanged(false); } -std::string MemoryCard::SanitizeGameTitleForFileName(const std::string_view& name) -{ - std::string ret(name); - - const u32 len = static_cast(ret.length()); - for (u32 i = 0; i < len; i++) - { - if (ret[i] == '\\' || ret[i] == '/' || ret[i] == '?' || ret[i] == '*') - ret[i] = '_'; - } - - return ret; -} - TickCount MemoryCard::GetSaveDelayInTicks() { return System::GetTicksPerSecond() * SAVE_DELAY_IN_SECONDS; diff --git a/src/core/memory_card.h b/src/core/memory_card.h index 4f4130163..daee8973d 100644 --- a/src/core/memory_card.h +++ b/src/core/memory_card.h @@ -20,8 +20,6 @@ public: static constexpr u32 STATE_SIZE = 1 + 1 + 2 + 1 + 1 + 1 + MemoryCardImage::DATA_SIZE + 1; - static std::string SanitizeGameTitleForFileName(const std::string_view& name); - static std::unique_ptr Create(); static std::unique_ptr Open(std::string_view filename); diff --git a/src/core/system.cpp b/src/core/system.cpp index 0b60cd56f..d95ab38cb 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -3068,21 +3068,18 @@ std::unique_ptr System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp // Playlist - use title if different. if (HasMediaSubImages() && s_running_game_entry && s_running_game_title != s_running_game_entry->title) { - card_path = - g_settings.GetGameMemoryCardPath(MemoryCard::SanitizeGameTitleForFileName(s_running_game_title), slot); + card_path = g_settings.GetGameMemoryCardPath(Path::SanitizeFileName(s_running_game_title), slot); } // Multi-disc game - use disc set name. else if (s_running_game_entry && !s_running_game_entry->disc_set_name.empty()) { - card_path = g_settings.GetGameMemoryCardPath( - MemoryCard::SanitizeGameTitleForFileName(s_running_game_entry->disc_set_name), slot); + card_path = + g_settings.GetGameMemoryCardPath(Path::SanitizeFileName(s_running_game_entry->disc_set_name), slot); } // But prefer a disc-specific card if one already exists. - std::string disc_card_path = - g_settings.GetGameMemoryCardPath(MemoryCard::SanitizeGameTitleForFileName( - s_running_game_entry ? s_running_game_entry->title : s_running_game_title), - slot); + std::string disc_card_path = g_settings.GetGameMemoryCardPath( + Path::SanitizeFileName(s_running_game_entry ? s_running_game_entry->title : s_running_game_title), slot); if (disc_card_path != card_path) { if (card_path.empty() || !g_settings.memory_card_use_playlist_title || @@ -3122,8 +3119,7 @@ std::unique_ptr System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp else { Host::RemoveKeyedOSDMessage(std::move(message_key)); - return MemoryCard::Open( - g_settings.GetGameMemoryCardPath(MemoryCard::SanitizeGameTitleForFileName(file_title).c_str(), slot)); + return MemoryCard::Open(g_settings.GetGameMemoryCardPath(Path::SanitizeFileName(file_title).c_str(), slot)); } } diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 398c1d506..6650aee64 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -856,12 +856,11 @@ void MainWindow::populateGameListContextMenu(const GameList::Entry* entry, QWidg break; case MemoryCardType::PerGameTitle: { - paths[i] = QString::fromStdString( - g_settings.GetGameMemoryCardPath(MemoryCard::SanitizeGameTitleForFileName(entry->title), i)); + paths[i] = QString::fromStdString(g_settings.GetGameMemoryCardPath(Path::SanitizeFileName(entry->title), i)); if (!entry->disc_set_name.empty() && g_settings.memory_card_use_playlist_title && !QFile::exists(paths[i])) { - paths[i] = QString::fromStdString( - g_settings.GetGameMemoryCardPath(MemoryCard::SanitizeGameTitleForFileName(entry->disc_set_name), i)); + paths[i] = + QString::fromStdString(g_settings.GetGameMemoryCardPath(Path::SanitizeFileName(entry->disc_set_name), i)); } } break; @@ -869,8 +868,8 @@ void MainWindow::populateGameListContextMenu(const GameList::Entry* entry, QWidg case MemoryCardType::PerGameFileTitle: { const std::string display_name(FileSystem::GetDisplayNameFromPath(entry->path)); - paths[i] = QString::fromStdString(g_settings.GetGameMemoryCardPath( - MemoryCard::SanitizeGameTitleForFileName(Path::GetFileTitle(display_name)), i)); + paths[i] = QString::fromStdString( + g_settings.GetGameMemoryCardPath(Path::SanitizeFileName(Path::GetFileTitle(display_name)), i)); } break; default: @@ -1086,8 +1085,7 @@ void MainWindow::onCheatsActionTriggered() void MainWindow::onCheatsMenuAboutToShow() { m_ui.menuCheats->clear(); - connect(m_ui.menuCheats->addAction(tr("Cheat Manager")), &QAction::triggered, this, - &MainWindow::openCheatManager); + connect(m_ui.menuCheats->addAction(tr("Cheat Manager")), &QAction::triggered, this, &MainWindow::openCheatManager); m_ui.menuCheats->addSeparator(); populateCheatsMenu(m_ui.menuCheats); }