summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-03-30 17:30:37 +0200
committerGitHub <noreply@github.com>2021-03-30 17:30:37 +0200
commit06439a2d40a06179633301e91ee85fa3059506fa (patch)
treebab30da0c79a1851492888f88beb8d1661156e70 /Source/Core
parent7a16231e98687457afedaa2b848e95e020a148c7 (diff)
parentd4b7ed4e38a1bb7218f615857d882e8ae74fa6c9 (diff)
Merge pull request #9610 from CookiePLMonster/fix-shortcut-creation
Fix shortcut creation
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinQt/GameList/GameList.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp
index f5f0c8d959..bf0806c88e 100644
--- a/Source/Core/DolphinQt/GameList/GameList.cpp
+++ b/Source/Core/DolphinQt/GameList/GameList.cpp
@@ -685,7 +685,18 @@ bool GameList::AddShortcutToDesktop()
if (FAILED(SHGetKnownFolderPath(FOLDERID_Desktop, KF_FLAG_NO_ALIAS, nullptr, &desktop)))
return false;
- const auto& game_name = game->GetLongName();
+ std::string game_name = game->GetName(Core::TitleDatabase());
+ // Sanitize the string by removing all characters that cannot be used in NTFS file names
+ game_name.erase(std::remove_if(game_name.begin(), game_name.end(),
+ [](char ch) {
+ static constexpr char illegal_characters[] = {
+ '<', '>', ':', '\"', '/', '\\', '|', '?', '*'};
+ return std::find(std::begin(illegal_characters),
+ std::end(illegal_characters),
+ ch) != std::end(illegal_characters);
+ }),
+ game_name.end());
+
std::wstring desktop_path = std::wstring(desktop.get()) + UTF8ToTStr("\\" + game_name + ".lnk");
auto persist_file = shell_link.try_query<IPersistFile>();
if (!persist_file)