diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/file_sys/registered_cache.cpp | 11 | ||||
| -rw-r--r-- | src/core/file_sys/registered_cache.h | 7 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 1febb398e..d1dea5e82 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 5 | #include <regex> | 6 | #include <regex> |
| 6 | #include <mbedtls/sha256.h> | 7 | #include <mbedtls/sha256.h> |
| 7 | #include "common/assert.h" | 8 | #include "common/assert.h" |
| @@ -30,6 +31,10 @@ bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs) | |||
| 30 | return (lhs.title_id < rhs.title_id) || (lhs.title_id == rhs.title_id && lhs.type < rhs.type); | 31 | return (lhs.title_id < rhs.title_id) || (lhs.title_id == rhs.title_id && lhs.type < rhs.type); |
| 31 | } | 32 | } |
| 32 | 33 | ||
| 34 | bool operator==(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs) { | ||
| 35 | return std::tie(lhs.title_id, lhs.type) == std::tie(rhs.title_id, rhs.type); | ||
| 36 | } | ||
| 37 | |||
| 33 | static bool FollowsTwoDigitDirFormat(std::string_view name) { | 38 | static bool FollowsTwoDigitDirFormat(std::string_view name) { |
| 34 | static const std::regex two_digit_regex("000000[0-9A-F]{2}", std::regex_constants::ECMAScript | | 39 | static const std::regex two_digit_regex("000000[0-9A-F]{2}", std::regex_constants::ECMAScript | |
| 35 | std::regex_constants::icase); | 40 | std::regex_constants::icase); |
| @@ -593,6 +598,9 @@ std::vector<RegisteredCacheEntry> RegisteredCacheUnion::ListEntries() const { | |||
| 593 | }, | 598 | }, |
| 594 | [](const CNMT& c, const ContentRecord& r) { return true; }); | 599 | [](const CNMT& c, const ContentRecord& r) { return true; }); |
| 595 | } | 600 | } |
| 601 | |||
| 602 | std::sort(out.begin(), out.end()); | ||
| 603 | out.erase(std::unique(out.begin(), out.end()), out.end()); | ||
| 596 | return out; | 604 | return out; |
| 597 | } | 605 | } |
| 598 | 606 | ||
| @@ -616,6 +624,9 @@ std::vector<RegisteredCacheEntry> RegisteredCacheUnion::ListEntriesFilter( | |||
| 616 | return true; | 624 | return true; |
| 617 | }); | 625 | }); |
| 618 | } | 626 | } |
| 627 | |||
| 628 | std::sort(out.begin(), out.end()); | ||
| 629 | out.erase(std::unique(out.begin(), out.end()), out.end()); | ||
| 619 | return out; | 630 | return out; |
| 620 | } | 631 | } |
| 621 | } // namespace FileSys | 632 | } // namespace FileSys |
diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index 5ddacba47..aeb1c69ba 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h | |||
| @@ -50,6 +50,9 @@ constexpr u64 GetUpdateTitleID(u64 base_title_id) { | |||
| 50 | // boost flat_map requires operator< for O(log(n)) lookups. | 50 | // boost flat_map requires operator< for O(log(n)) lookups. |
| 51 | bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs); | 51 | bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs); |
| 52 | 52 | ||
| 53 | // std unique requires operator== to identify duplicates. | ||
| 54 | bool operator==(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs); | ||
| 55 | |||
| 53 | /* | 56 | /* |
| 54 | * A class that catalogues NCAs in the registered directory structure. | 57 | * A class that catalogues NCAs in the registered directory structure. |
| 55 | * Nintendo's registered format follows this structure: | 58 | * Nintendo's registered format follows this structure: |
| @@ -60,8 +63,8 @@ bool operator<(const RegisteredCacheEntry& lhs, const RegisteredCacheEntry& rhs) | |||
| 60 | * | 00 | 63 | * | 00 |
| 61 | * | 01 <- Actual content split along 4GB boundaries. (optional) | 64 | * | 01 <- Actual content split along 4GB boundaries. (optional) |
| 62 | * | 65 | * |
| 63 | * (This impl also supports substituting the nca dir for an nca file, as that's more convenient when | 66 | * (This impl also supports substituting the nca dir for an nca file, as that's more convenient |
| 64 | * 4GB splitting can be ignored.) | 67 | * when 4GB splitting can be ignored.) |
| 65 | */ | 68 | */ |
| 66 | class RegisteredCache { | 69 | class RegisteredCache { |
| 67 | friend class RegisteredCacheUnion; | 70 | friend class RegisteredCacheUnion; |