FileSystem: Purge GetDisplayNameFromPath()

Redundant function.
This commit is contained in:
Stenzek 2023-12-22 19:16:04 +10:00 committed by Connor McLaughlin
parent 9967d5ca9e
commit d73d698fd5
6 changed files with 13 additions and 24 deletions

View File

@ -531,11 +531,6 @@ static std::string_view::size_type GetLastSeperatorPosition(const std::string_vi
return last_separator;
}
std::string FileSystem::GetDisplayNameFromPath(const std::string_view& path)
{
return std::string(Path::GetFileName(path));
}
std::string_view Path::GetDirectory(const std::string_view& path)
{
const std::string::size_type pos = GetLastSeperatorPosition(path, false);

View File

@ -71,9 +71,6 @@ namespace FileSystem
{
using FindResultsArray = std::vector<FILESYSTEM_FIND_DATA>;
/// Returns the display name of a filename. Usually this is the same as the path.
std::string GetDisplayNameFromPath(const std::string_view& path);
/// Returns a list of "root directories" (i.e. root/home directories on Linux, drive letters on Windows).
std::vector<std::string> GetRootDirectoryList();

View File

@ -366,7 +366,7 @@ bool DoCDVDopen(Error* error)
return true;
}
std::string dump_name(Path::StripExtension(FileSystem::GetDisplayNameFromPath(m_SourceFilename[CurrentSourceType])));
std::string dump_name(Path::StripExtension(m_SourceFilename[CurrentSourceType]));
if (dump_name.empty())
dump_name = "Untitled";

View File

@ -200,7 +200,7 @@ bool GameList::GetElfListEntry(const std::string& path, GameList::Entry* entry)
entry->path = path;
entry->serial.clear();
entry->title = Path::GetFileTitle(FileSystem::GetDisplayNameFromPath(path));
entry->title = Path::GetFileTitle(path);
entry->region = Region::Other;
entry->type = EntryType::ELF;
entry->compatibility_rating = CompatibilityRating::Unknown;
@ -632,7 +632,8 @@ void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache,
continue;
}
progress->SetFormattedStatusText("Scanning '%s'...", FileSystem::GetDisplayNameFromPath(ffd.FileName).c_str());
const std::string_view filename = Path::GetFileName(ffd.FileName);
progress->SetFormattedStatusText("Scanning '%.*s'...", static_cast<int>(filename.size()), filename.data());
ScanFile(std::move(ffd.FileName), ffd.ModificationTime, lock, played_time_map, custom_attributes_ini);
progress->SetProgressValue(files_scanned);
}
@ -1269,10 +1270,7 @@ bool GameList::DownloadCovers(const std::vector<std::string>& url_templates, boo
if (has_title)
StringUtil::ReplaceAll(&url, "${title}", HTTPDownloader::URLEncode(entry.title));
if (has_file_title)
{
std::string display_name(FileSystem::GetDisplayNameFromPath(entry.path));
StringUtil::ReplaceAll(&url, "${filetitle}", HTTPDownloader::URLEncode(Path::GetFileTitle(display_name)));
}
StringUtil::ReplaceAll(&url, "${filetitle}", HTTPDownloader::URLEncode(Path::GetFileTitle(entry.path)));
if (has_serial)
StringUtil::ReplaceAll(&url, "${serial}", HTTPDownloader::URLEncode(entry.serial));

View File

@ -1004,7 +1004,7 @@ void FullscreenUI::DoChangeDiscFromFile()
{
if (!VMManager::IsDiscFileName(path))
{
ShowToast({}, fmt::format(FSUI_FSTR("{} is not a valid disc image."), FileSystem::GetDisplayNameFromPath(path)));
ShowToast({}, fmt::format(FSUI_FSTR("{} is not a valid disc image."), Path::GetFileName(path)));
}
else
{

View File

@ -841,7 +841,7 @@ void VMManager::UpdateDiscDetails(bool booting)
}
else if (!s_elf_override.empty())
{
s_disc_serial = Path::GetFileTitle(FileSystem::GetDisplayNameFromPath(s_elf_override));
s_disc_serial = Path::GetFileTitle(s_elf_override);
s_disc_version = {};
s_disc_crc = 0; // set below
}
@ -884,7 +884,7 @@ void VMManager::UpdateDiscDetails(bool booting)
if (!s_elf_override.empty())
{
title = fmt::format(
"{} [{}]", game_title, Path::GetFileTitle(FileSystem::GetDisplayNameFromPath(s_elf_override)));
"{} [{}]", game_title, Path::GetFileTitle(s_elf_override));
}
else
{
@ -1025,13 +1025,12 @@ bool VMManager::AutoDetectSource(const std::string& filename)
return false;
}
const std::string display_name(FileSystem::GetDisplayNameFromPath(filename));
if (IsGSDumpFileName(display_name))
if (IsGSDumpFileName(filename))
{
CDVDsys_ChangeSource(CDVD_SourceType::NoDisc);
return GSDumpReplayer::Initialize(filename.c_str());
}
else if (IsElfFileName(display_name))
else if (IsElfFileName(filename))
{
// alternative way of booting an elf, change the elf override, and (optionally) use the disc
// specified in the game settings.
@ -2015,7 +2014,6 @@ bool VMManager::ChangeDisc(CDVD_SourceType source, std::string path)
const CDVD_SourceType old_type = CDVDsys_GetSourceType();
const std::string old_path(CDVDsys_GetFile(old_type));
const std::string display_name((source != CDVD_SourceType::Iso) ? path : FileSystem::GetDisplayNameFromPath(path));
CDVDsys_ChangeSource(source);
if (!path.empty())
CDVDsys_SetFile(source, std::move(path));
@ -2032,7 +2030,8 @@ bool VMManager::ChangeDisc(CDVD_SourceType source, std::string path)
else
{
Host::AddIconOSDMessage("ChangeDisc", ICON_FA_COMPACT_DISC,
fmt::format(TRANSLATE_FS("VMManager", "Disc changed to '{}'."), display_name), Host::OSD_INFO_DURATION);
fmt::format(TRANSLATE_FS("VMManager", "Disc changed to '{}'."), Path::GetFileName(path)),
Host::OSD_INFO_DURATION);
}
}
else
@ -2040,7 +2039,7 @@ bool VMManager::ChangeDisc(CDVD_SourceType source, std::string path)
Host::AddIconOSDMessage("ChangeDisc", ICON_FA_COMPACT_DISC,
fmt::format(
TRANSLATE_FS("VMManager", "Failed to open new disc image '{}'. Reverting to old image.\nError was: {}"),
display_name, error.GetDescription()),
Path::GetFileName(path), error.GetDescription()),
Host::OSD_ERROR_DURATION);
CDVDsys_ChangeSource(old_type);
if (!old_path.empty())