diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 15 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.h | 12 |
2 files changed, 12 insertions, 15 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index c228d253e..e91ff968c 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include "core/settings.h" | 27 | #include "core/settings.h" |
| 28 | 28 | ||
| 29 | namespace FileSys { | 29 | namespace FileSys { |
| 30 | namespace { | ||
| 30 | 31 | ||
| 31 | constexpr u64 SINGLE_BYTE_MODULUS = 0x100; | 32 | constexpr u64 SINGLE_BYTE_MODULUS = 0x100; |
| 32 | constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; | 33 | constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; |
| @@ -36,7 +37,13 @@ constexpr std::array<const char*, 14> EXEFS_FILE_NAMES{ | |||
| 36 | "subsdk3", "subsdk4", "subsdk5", "subsdk6", "subsdk7", "subsdk8", "subsdk9", | 37 | "subsdk3", "subsdk4", "subsdk5", "subsdk6", "subsdk7", "subsdk8", "subsdk9", |
| 37 | }; | 38 | }; |
| 38 | 39 | ||
| 39 | std::string FormatTitleVersion(u32 version, TitleVersionFormat format) { | 40 | enum class TitleVersionFormat : u8 { |
| 41 | ThreeElements, ///< vX.Y.Z | ||
| 42 | FourElements, ///< vX.Y.Z.W | ||
| 43 | }; | ||
| 44 | |||
| 45 | std::string FormatTitleVersion(u32 version, | ||
| 46 | TitleVersionFormat format = TitleVersionFormat::ThreeElements) { | ||
| 40 | std::array<u8, sizeof(u32)> bytes{}; | 47 | std::array<u8, sizeof(u32)> bytes{}; |
| 41 | bytes[0] = version % SINGLE_BYTE_MODULUS; | 48 | bytes[0] = version % SINGLE_BYTE_MODULUS; |
| 42 | for (std::size_t i = 1; i < bytes.size(); ++i) { | 49 | for (std::size_t i = 1; i < bytes.size(); ++i) { |
| @@ -49,6 +56,8 @@ std::string FormatTitleVersion(u32 version, TitleVersionFormat format) { | |||
| 49 | return fmt::format("v{}.{}.{}", bytes[3], bytes[2], bytes[1]); | 56 | return fmt::format("v{}.{}.{}", bytes[3], bytes[2], bytes[1]); |
| 50 | } | 57 | } |
| 51 | 58 | ||
| 59 | // Returns a directory with name matching name case-insensitive. Returns nullptr if directory | ||
| 60 | // doesn't have a directory with name. | ||
| 52 | VirtualDir FindSubdirectoryCaseless(const VirtualDir dir, std::string_view name) { | 61 | VirtualDir FindSubdirectoryCaseless(const VirtualDir dir, std::string_view name) { |
| 53 | #ifdef _WIN32 | 62 | #ifdef _WIN32 |
| 54 | return dir->GetSubdirectory(name); | 63 | return dir->GetSubdirectory(name); |
| @@ -64,6 +73,7 @@ VirtualDir FindSubdirectoryCaseless(const VirtualDir dir, std::string_view name) | |||
| 64 | return nullptr; | 73 | return nullptr; |
| 65 | #endif | 74 | #endif |
| 66 | } | 75 | } |
| 76 | } // Anonymous namespace | ||
| 67 | 77 | ||
| 68 | PatchManager::PatchManager(u64 title_id) : title_id(title_id) {} | 78 | PatchManager::PatchManager(u64 title_id) : title_id(title_id) {} |
| 69 | 79 | ||
| @@ -472,8 +482,7 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam | |||
| 472 | if (meta_ver.value_or(0) == 0) { | 482 | if (meta_ver.value_or(0) == 0) { |
| 473 | out.insert_or_assign(update_label, ""); | 483 | out.insert_or_assign(update_label, ""); |
| 474 | } else { | 484 | } else { |
| 475 | out.insert_or_assign( | 485 | out.insert_or_assign(update_label, FormatTitleVersion(*meta_ver)); |
| 476 | update_label, FormatTitleVersion(*meta_ver, TitleVersionFormat::ThreeElements)); | ||
| 477 | } | 486 | } |
| 478 | } else if (update_raw != nullptr) { | 487 | } else if (update_raw != nullptr) { |
| 479 | out.insert_or_assign(update_label, "PACKED"); | 488 | out.insert_or_assign(update_label, "PACKED"); |
diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index 532f4995f..92a7c6e04 100644 --- a/src/core/file_sys/patch_manager.h +++ b/src/core/file_sys/patch_manager.h | |||
| @@ -22,18 +22,6 @@ namespace FileSys { | |||
| 22 | class NCA; | 22 | class NCA; |
| 23 | class NACP; | 23 | class NACP; |
| 24 | 24 | ||
| 25 | enum class TitleVersionFormat : u8 { | ||
| 26 | ThreeElements, ///< vX.Y.Z | ||
| 27 | FourElements, ///< vX.Y.Z.W | ||
| 28 | }; | ||
| 29 | |||
| 30 | std::string FormatTitleVersion(u32 version, | ||
| 31 | TitleVersionFormat format = TitleVersionFormat::ThreeElements); | ||
| 32 | |||
| 33 | // Returns a directory with name matching name case-insensitive. Returns nullptr if directory | ||
| 34 | // doesn't have a directory with name. | ||
| 35 | VirtualDir FindSubdirectoryCaseless(VirtualDir dir, std::string_view name); | ||
| 36 | |||
| 37 | // A centralized class to manage patches to games. | 25 | // A centralized class to manage patches to games. |
| 38 | class PatchManager { | 26 | class PatchManager { |
| 39 | public: | 27 | public: |