diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index 3afb09873f..c44f3fa7b1 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -322,6 +322,13 @@ bool SplitPath(std::string_view full_path, std::string* path, std::string* filen return true; } +std::string PathToFileName(std::string_view path) +{ + std::string file_name, extension; + SplitPath(path, nullptr, &file_name, &extension); + return file_name + extension; +} + void BuildCompleteFilename(std::string& complete_filename, std::string_view path, std::string_view filename) { diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h index 211c381abf..969c6e9ea1 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -159,6 +159,8 @@ std::string JoinStrings(const std::vector& strings, const std::stri bool SplitPath(std::string_view full_path, std::string* path, std::string* filename, std::string* extension); +std::string PathToFileName(std::string_view path); + void BuildCompleteFilename(std::string& complete_filename, std::string_view path, std::string_view filename); diff --git a/Source/Core/DolphinQt/Settings/InterfacePane.cpp b/Source/Core/DolphinQt/Settings/InterfacePane.cpp index 0de6099cea..8281ae0132 100644 --- a/Source/Core/DolphinQt/Settings/InterfacePane.cpp +++ b/Source/Core/DolphinQt/Settings/InterfacePane.cpp @@ -119,12 +119,9 @@ void InterfacePane::CreateUI() // List avalable themes auto theme_search_results = Common::DoFileSearch({File::GetUserPath(D_THEMES_IDX), File::GetSysDirectory() + THEMES_DIR}); - for (const std::string& filename : theme_search_results) + for (const std::string& path : theme_search_results) { - std::string name, ext; - SplitPath(filename, nullptr, &name, &ext); - name += ext; - QString qt_name = QString::fromStdString(name); + const QString qt_name = QString::fromStdString(PathToFileName(path)); m_combobox_theme->addItem(qt_name); } @@ -137,12 +134,12 @@ void InterfacePane::CreateUI() m_combobox_userstyle->addItem(tr("(None)"), QString{}); - for (const std::string& filename : userstyle_search_results) + for (const std::string& path : userstyle_search_results) { - std::string name, ext; - SplitPath(filename, nullptr, &name, &ext); - QString qt_name = QString::fromStdString(name); - m_combobox_userstyle->addItem(qt_name, QString::fromStdString(filename)); + std::string name; + SplitPath(path, nullptr, &name, nullptr); + const QString qt_name = QString::fromStdString(name); + m_combobox_userstyle->addItem(qt_name, QString::fromStdString(path)); } // Checkboxes diff --git a/Source/Core/UICommon/GameFile.cpp b/Source/Core/UICommon/GameFile.cpp index 8499d270f4..cc64d9d3e9 100644 --- a/Source/Core/UICommon/GameFile.cpp +++ b/Source/Core/UICommon/GameFile.cpp @@ -97,11 +97,9 @@ GameFile::GameFile() = default; GameFile::GameFile(std::string path) : m_file_path(std::move(path)) { - { - std::string name, extension; - SplitPath(m_file_path, nullptr, &name, &extension); - m_file_name = name + extension; + m_file_name = PathToFileName(m_file_path); + { std::unique_ptr volume(DiscIO::CreateVolume(m_file_path)); if (volume != nullptr) {