diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2023-01-24 21:51:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-24 21:51:15 +0100 |
| commit | 4b2c00e239f44e79190cc156e4557ea4aaf64bd2 (patch) | |
| tree | 09ec8ac31ff935d63aa9c06004802156ac96ebf5 /Source/Core/DiscIO | |
| parent | ba6ee9d7ba9730e5b2165ff0ee18cbc23762b129 (diff) | |
| parent | e5b91f00b0688d5cba6870da6d6ad3300097b07f (diff) | |
Merge pull request #11487 from lioncash/str
Common: Replace StringBeginsWith/StringEndsWith with std equivalents
Diffstat (limited to 'Source/Core/DiscIO')
| -rw-r--r-- | Source/Core/DiscIO/RiivolutionParser.cpp | 6 | ||||
| -rw-r--r-- | Source/Core/DiscIO/RiivolutionPatcher.cpp | 12 | ||||
| -rw-r--r-- | Source/Core/DiscIO/VolumeVerifier.cpp | 10 |
3 files changed, 14 insertions, 14 deletions
diff --git a/Source/Core/DiscIO/RiivolutionParser.cpp b/Source/Core/DiscIO/RiivolutionParser.cpp index dacbbbcfc5..656cd20697 100644 --- a/Source/Core/DiscIO/RiivolutionParser.cpp +++ b/Source/Core/DiscIO/RiivolutionParser.cpp @@ -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); diff --git a/Source/Core/DiscIO/RiivolutionPatcher.cpp b/Source/Core/DiscIO/RiivolutionPatcher.cpp index 840acf768b..eb0ca53137 100644 --- a/Source/Core/DiscIO/RiivolutionPatcher.cpp +++ b/Source/Core/DiscIO/RiivolutionPatcher.cpp @@ -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); }; diff --git a/Source/Core/DiscIO/VolumeVerifier.cpp b/Source/Core/DiscIO/VolumeVerifier.cpp index c6392d446b..855142143f 100644 --- a/Source/Core/DiscIO/VolumeVerifier.cpp +++ b/Source/Core/DiscIO/VolumeVerifier.cpp @@ -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(); } |
