StringUtil: Add PathToFileName function
This commit is contained in:
parent
c86832849a
commit
5f6598f9e9
|
@ -322,6 +322,13 @@ bool SplitPath(std::string_view full_path, std::string* path, std::string* filen
|
||||||
return true;
|
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,
|
void BuildCompleteFilename(std::string& complete_filename, std::string_view path,
|
||||||
std::string_view filename)
|
std::string_view filename)
|
||||||
{
|
{
|
||||||
|
|
|
@ -159,6 +159,8 @@ std::string JoinStrings(const std::vector<std::string>& strings, const std::stri
|
||||||
bool SplitPath(std::string_view full_path, std::string* path, std::string* filename,
|
bool SplitPath(std::string_view full_path, std::string* path, std::string* filename,
|
||||||
std::string* extension);
|
std::string* extension);
|
||||||
|
|
||||||
|
std::string PathToFileName(std::string_view path);
|
||||||
|
|
||||||
void BuildCompleteFilename(std::string& complete_filename, std::string_view path,
|
void BuildCompleteFilename(std::string& complete_filename, std::string_view path,
|
||||||
std::string_view filename);
|
std::string_view filename);
|
||||||
|
|
||||||
|
|
|
@ -119,12 +119,9 @@ void InterfacePane::CreateUI()
|
||||||
// List avalable themes
|
// List avalable themes
|
||||||
auto theme_search_results =
|
auto theme_search_results =
|
||||||
Common::DoFileSearch({File::GetUserPath(D_THEMES_IDX), File::GetSysDirectory() + THEMES_DIR});
|
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;
|
const QString qt_name = QString::fromStdString(PathToFileName(path));
|
||||||
SplitPath(filename, nullptr, &name, &ext);
|
|
||||||
name += ext;
|
|
||||||
QString qt_name = QString::fromStdString(name);
|
|
||||||
m_combobox_theme->addItem(qt_name);
|
m_combobox_theme->addItem(qt_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,12 +134,12 @@ void InterfacePane::CreateUI()
|
||||||
|
|
||||||
m_combobox_userstyle->addItem(tr("(None)"), QString{});
|
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;
|
std::string name;
|
||||||
SplitPath(filename, nullptr, &name, &ext);
|
SplitPath(path, nullptr, &name, nullptr);
|
||||||
QString qt_name = QString::fromStdString(name);
|
const QString qt_name = QString::fromStdString(name);
|
||||||
m_combobox_userstyle->addItem(qt_name, QString::fromStdString(filename));
|
m_combobox_userstyle->addItem(qt_name, QString::fromStdString(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checkboxes
|
// Checkboxes
|
||||||
|
|
|
@ -97,11 +97,9 @@ GameFile::GameFile() = default;
|
||||||
|
|
||||||
GameFile::GameFile(std::string path) : m_file_path(std::move(path))
|
GameFile::GameFile(std::string path) : m_file_path(std::move(path))
|
||||||
{
|
{
|
||||||
{
|
m_file_name = PathToFileName(m_file_path);
|
||||||
std::string name, extension;
|
|
||||||
SplitPath(m_file_path, nullptr, &name, &extension);
|
|
||||||
m_file_name = name + extension;
|
|
||||||
|
|
||||||
|
{
|
||||||
std::unique_ptr<DiscIO::Volume> volume(DiscIO::CreateVolume(m_file_path));
|
std::unique_ptr<DiscIO::Volume> volume(DiscIO::CreateVolume(m_file_path));
|
||||||
if (volume != nullptr)
|
if (volume != nullptr)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue