mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 07:09:48 -06:00
Common: Replace StringBeginsWith/StringEndsWith with std equivalents
Obsoletes these functions in favor of the standard member functions added in C++20.
This commit is contained in:
@ -53,7 +53,7 @@ static std::vector<u8> ReadHexString(std::string_view sv)
|
||||
{
|
||||
if ((sv.size() % 2) == 1)
|
||||
return {};
|
||||
if (StringBeginsWith(sv, "0x") || StringBeginsWith(sv, "0X"))
|
||||
if (sv.starts_with("0x") || sv.starts_with("0X"))
|
||||
sv = sv.substr(2);
|
||||
|
||||
std::vector<u8> result;
|
||||
@ -245,7 +245,7 @@ bool Disc::IsValidForGame(const std::string& game_id, std::optional<u16> revisio
|
||||
const int disc_number_int = std::optional<int>(disc_number).value_or(-1);
|
||||
const int revision_int = std::optional<int>(revision).value_or(-1);
|
||||
|
||||
if (m_game_filter.m_game && !StringBeginsWith(game_id_full, *m_game_filter.m_game))
|
||||
if (m_game_filter.m_game && !game_id_full.starts_with(*m_game_filter.m_game))
|
||||
return false;
|
||||
if (m_game_filter.m_developer && game_developer != *m_game_filter.m_developer)
|
||||
return false;
|
||||
@ -276,7 +276,7 @@ std::vector<Patch> Disc::GeneratePatches(const std::string& game_id) const
|
||||
bool replaced = false;
|
||||
for (const auto& r : replacements)
|
||||
{
|
||||
if (StringBeginsWith(sv, r.first))
|
||||
if (sv.starts_with(r.first))
|
||||
{
|
||||
for (char c : r.second)
|
||||
result.push_back(c);
|
||||
|
@ -64,13 +64,13 @@ FileDataLoaderHostFS::MakeAbsoluteFromRelative(std::string_view external_relativ
|
||||
return std::nullopt;
|
||||
#endif
|
||||
|
||||
std::string result = StringBeginsWith(external_relative_path, "/") ? m_sd_root : m_patch_root;
|
||||
std::string result = external_relative_path.starts_with('/') ? m_sd_root : m_patch_root;
|
||||
std::string_view work = external_relative_path;
|
||||
|
||||
// Strip away all leading and trailing path separators.
|
||||
while (StringBeginsWith(work, "/"))
|
||||
while (work.starts_with('/'))
|
||||
work.remove_prefix(1);
|
||||
while (StringEndsWith(work, "/"))
|
||||
while (work.ends_with('/'))
|
||||
work.remove_suffix(1);
|
||||
size_t depth = 0;
|
||||
while (true)
|
||||
@ -126,7 +126,7 @@ FileDataLoaderHostFS::MakeAbsoluteFromRelative(std::string_view external_relativ
|
||||
work = work.substr(separator_position + 1);
|
||||
|
||||
// Remove any potential extra path separators.
|
||||
while (StringBeginsWith(work, "/"))
|
||||
while (work.starts_with('/'))
|
||||
work = work.substr(1);
|
||||
}
|
||||
return result;
|
||||
@ -425,9 +425,9 @@ static void ApplyFolderPatchToFST(const Patch& patch, const Folder& folder,
|
||||
return std::string(b);
|
||||
if (b.empty())
|
||||
return std::string(a);
|
||||
if (StringEndsWith(a, "/"))
|
||||
if (a.ends_with('/'))
|
||||
a.remove_suffix(1);
|
||||
if (StringBeginsWith(b, "/"))
|
||||
if (b.starts_with('/'))
|
||||
b.remove_prefix(1);
|
||||
return fmt::format("{}/{}", a, b);
|
||||
};
|
||||
|
@ -247,7 +247,7 @@ std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const st
|
||||
if (version % 0x30 != m_revision % 0x30)
|
||||
continue;
|
||||
|
||||
if (serials.empty() || StringBeginsWith(serials, "DS"))
|
||||
if (serials.empty() || serials.starts_with("DS"))
|
||||
{
|
||||
// GC Datel discs have no serials in Redump, Wii Datel discs have serials like "DS000101"
|
||||
if (!m_game_id.empty())
|
||||
@ -666,7 +666,7 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
|
||||
{
|
||||
std::string file_name = f.GetName();
|
||||
Common::ToLower(&file_name);
|
||||
if (StringBeginsWith(file_name, correct_ios))
|
||||
if (file_name.starts_with(correct_ios))
|
||||
{
|
||||
has_correct_ios = true;
|
||||
break;
|
||||
@ -865,13 +865,13 @@ void VolumeVerifier::CheckMisc()
|
||||
bool inconsistent_game_id = true;
|
||||
if (game_id_encrypted == "RELSAB")
|
||||
{
|
||||
if (StringBeginsWith(game_id_unencrypted, "410"))
|
||||
if (game_id_unencrypted.starts_with("410"))
|
||||
{
|
||||
// This is the Wii Backup Disc (aka "pinkfish" disc),
|
||||
// which legitimately has an inconsistent game ID.
|
||||
inconsistent_game_id = false;
|
||||
}
|
||||
else if (StringBeginsWith(game_id_unencrypted, "010"))
|
||||
else if (game_id_unencrypted.starts_with("010"))
|
||||
{
|
||||
// Hacked version of the Wii Backup Disc (aka "pinkfish" disc).
|
||||
std::string proper_game_id = game_id_unencrypted;
|
||||
@ -1016,7 +1016,7 @@ void VolumeVerifier::CheckMisc()
|
||||
"though the files are not identical."));
|
||||
}
|
||||
|
||||
if (IsDisc(m_volume.GetVolumeType()) && StringBeginsWith(game_id_unencrypted, "R8P"))
|
||||
if (IsDisc(m_volume.GetVolumeType()) && game_id_unencrypted.starts_with("R8P"))
|
||||
CheckSuperPaperMario();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user