diff options
| author | 2024-02-19 10:50:45 -0500 | |
|---|---|---|
| committer | 2024-02-19 10:50:45 -0500 | |
| commit | c9ef2e26ca82cacc44998727d704f4b77ee88591 (patch) | |
| tree | 43a5699123e4930560fc5016faac7efb15b63f4e /src/core/file_sys | |
| parent | Merge pull request #13006 from liamwhite/a-hat-in-vram (diff) | |
| parent | scope_exit: Make constexpr (diff) | |
| download | yuzu-c9ef2e26ca82cacc44998727d704f4b77ee88591.tar.gz yuzu-c9ef2e26ca82cacc44998727d704f4b77ee88591.tar.xz yuzu-c9ef2e26ca82cacc44998727d704f4b77ee88591.zip | |
Merge pull request #13080 from FearlessTobi/scope-exit
scope_exit: Make constexpr
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/fs_directory.h | 4 | ||||
| -rw-r--r-- | src/core/file_sys/fs_path_utility.h | 12 | ||||
| -rw-r--r-- | src/core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.cpp | 4 | ||||
| -rw-r--r-- | src/core/file_sys/program_metadata.cpp | 4 |
4 files changed, 16 insertions, 8 deletions
diff --git a/src/core/file_sys/fs_directory.h b/src/core/file_sys/fs_directory.h index 25c9cb18a..3f90abb8f 100644 --- a/src/core/file_sys/fs_directory.h +++ b/src/core/file_sys/fs_directory.h | |||
| @@ -3,6 +3,10 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <string_view> | ||
| 7 | #include "common/common_funcs.h" | ||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 6 | namespace FileSys { | 10 | namespace FileSys { |
| 7 | 11 | ||
| 8 | constexpr inline size_t EntryNameLengthMax = 0x300; | 12 | constexpr inline size_t EntryNameLengthMax = 0x300; |
diff --git a/src/core/file_sys/fs_path_utility.h b/src/core/file_sys/fs_path_utility.h index e9011d065..5643141f9 100644 --- a/src/core/file_sys/fs_path_utility.h +++ b/src/core/file_sys/fs_path_utility.h | |||
| @@ -447,7 +447,7 @@ public: | |||
| 447 | char* replacement_path = nullptr; | 447 | char* replacement_path = nullptr; |
| 448 | size_t replacement_path_size = 0; | 448 | size_t replacement_path_size = 0; |
| 449 | 449 | ||
| 450 | SCOPE_EXIT({ | 450 | SCOPE_EXIT { |
| 451 | if (replacement_path != nullptr) { | 451 | if (replacement_path != nullptr) { |
| 452 | if (std::is_constant_evaluated()) { | 452 | if (std::is_constant_evaluated()) { |
| 453 | delete[] replacement_path; | 453 | delete[] replacement_path; |
| @@ -455,7 +455,7 @@ public: | |||
| 455 | Deallocate(replacement_path, replacement_path_size); | 455 | Deallocate(replacement_path, replacement_path_size); |
| 456 | } | 456 | } |
| 457 | } | 457 | } |
| 458 | }); | 458 | }; |
| 459 | 459 | ||
| 460 | // Perform path replacement, if necessary | 460 | // Perform path replacement, if necessary |
| 461 | if (IsParentDirectoryPathReplacementNeeded(cur_path)) { | 461 | if (IsParentDirectoryPathReplacementNeeded(cur_path)) { |
| @@ -1102,8 +1102,8 @@ public: | |||
| 1102 | R_SUCCEED(); | 1102 | R_SUCCEED(); |
| 1103 | } | 1103 | } |
| 1104 | 1104 | ||
| 1105 | static Result Normalize(char* dst, size_t dst_size, const char* path, size_t path_len, | 1105 | static constexpr Result Normalize(char* dst, size_t dst_size, const char* path, size_t path_len, |
| 1106 | const PathFlags& flags) { | 1106 | const PathFlags& flags) { |
| 1107 | // Use StringTraits names for remainder of scope | 1107 | // Use StringTraits names for remainder of scope |
| 1108 | using namespace StringTraits; | 1108 | using namespace StringTraits; |
| 1109 | 1109 | ||
| @@ -1199,7 +1199,7 @@ public: | |||
| 1199 | const size_t replaced_src_len = path_len - (src - path); | 1199 | const size_t replaced_src_len = path_len - (src - path); |
| 1200 | 1200 | ||
| 1201 | char* replaced_src = nullptr; | 1201 | char* replaced_src = nullptr; |
| 1202 | SCOPE_EXIT({ | 1202 | SCOPE_EXIT { |
| 1203 | if (replaced_src != nullptr) { | 1203 | if (replaced_src != nullptr) { |
| 1204 | if (std::is_constant_evaluated()) { | 1204 | if (std::is_constant_evaluated()) { |
| 1205 | delete[] replaced_src; | 1205 | delete[] replaced_src; |
| @@ -1207,7 +1207,7 @@ public: | |||
| 1207 | Deallocate(replaced_src, replaced_src_len); | 1207 | Deallocate(replaced_src, replaced_src_len); |
| 1208 | } | 1208 | } |
| 1209 | } | 1209 | } |
| 1210 | }); | 1210 | }; |
| 1211 | 1211 | ||
| 1212 | if (std::is_constant_evaluated()) { | 1212 | if (std::is_constant_evaluated()) { |
| 1213 | replaced_src = new char[replaced_src_len]; | 1213 | replaced_src = new char[replaced_src_len]; |
diff --git a/src/core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.cpp b/src/core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.cpp index caea0b8f8..a68fd973c 100644 --- a/src/core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.cpp +++ b/src/core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.cpp | |||
| @@ -36,7 +36,9 @@ Result HierarchicalSha256Storage::Initialize(VirtualFile* base_storages, s32 lay | |||
| 36 | // Get the base storage size. | 36 | // Get the base storage size. |
| 37 | m_base_storage_size = base_storages[2]->GetSize(); | 37 | m_base_storage_size = base_storages[2]->GetSize(); |
| 38 | { | 38 | { |
| 39 | auto size_guard = SCOPE_GUARD({ m_base_storage_size = 0; }); | 39 | auto size_guard = SCOPE_GUARD { |
| 40 | m_base_storage_size = 0; | ||
| 41 | }; | ||
| 40 | R_UNLESS(m_base_storage_size <= static_cast<s64>(HashSize) | 42 | R_UNLESS(m_base_storage_size <= static_cast<s64>(HashSize) |
| 41 | << m_log_size_ratio << m_log_size_ratio, | 43 | << m_log_size_ratio << m_log_size_ratio, |
| 42 | ResultHierarchicalSha256BaseStorageTooLarge); | 44 | ResultHierarchicalSha256BaseStorageTooLarge); |
diff --git a/src/core/file_sys/program_metadata.cpp b/src/core/file_sys/program_metadata.cpp index ae4e441c9..289969cc4 100644 --- a/src/core/file_sys/program_metadata.cpp +++ b/src/core/file_sys/program_metadata.cpp | |||
| @@ -98,7 +98,9 @@ Loader::ResultStatus ProgramMetadata::Load(VirtualFile file) { | |||
| 98 | 98 | ||
| 99 | Loader::ResultStatus ProgramMetadata::Reload(VirtualFile file) { | 99 | Loader::ResultStatus ProgramMetadata::Reload(VirtualFile file) { |
| 100 | const u64 original_program_id = aci_header.title_id; | 100 | const u64 original_program_id = aci_header.title_id; |
| 101 | SCOPE_EXIT({ aci_header.title_id = original_program_id; }); | 101 | SCOPE_EXIT { |
| 102 | aci_header.title_id = original_program_id; | ||
| 103 | }; | ||
| 102 | 104 | ||
| 103 | return this->Load(file); | 105 | return this->Load(file); |
| 104 | } | 106 | } |