diff options
| author | 2018-08-18 21:16:20 -0400 | |
|---|---|---|
| committer | 2018-08-23 11:53:30 -0400 | |
| commit | a7e8d10969f280cd5a869b3525c3339357a958a6 (patch) | |
| tree | 59e34b73d627cffab8cdbdf7e52ffdd6168c54fc /src | |
| parent | crypto: Eliminate magic constants (diff) | |
| download | yuzu-a7e8d10969f280cd5a869b3525c3339357a958a6.tar.gz yuzu-a7e8d10969f280cd5a869b3525c3339357a958a6.tar.xz yuzu-a7e8d10969f280cd5a869b3525c3339357a958a6.zip | |
file_sys: Cut down on includes and copies
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/crypto/key_manager.cpp | 22 | ||||
| -rw-r--r-- | src/core/crypto/key_manager.h | 6 | ||||
| -rw-r--r-- | src/core/file_sys/registered_cache.cpp | 2 | ||||
| -rw-r--r-- | src/core/file_sys/registered_cache.h | 1 | ||||
| -rw-r--r-- | src/core/file_sys/sdmc_factory.h | 3 | ||||
| -rw-r--r-- | src/core/loader/nax.cpp | 2 | ||||
| -rw-r--r-- | src/core/loader/nax.h | 13 |
7 files changed, 30 insertions, 19 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index acf635a65..1cb3fce00 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp | |||
| @@ -199,7 +199,7 @@ Key256 KeyManager::GetKey(S256KeyType id, u64 field1, u64 field2) const { | |||
| 199 | 199 | ||
| 200 | template <size_t Size> | 200 | template <size_t Size> |
| 201 | void KeyManager::WriteKeyToFile(bool title_key, std::string_view keyname, | 201 | void KeyManager::WriteKeyToFile(bool title_key, std::string_view keyname, |
| 202 | std::array<u8, Size> key) { | 202 | const std::array<u8, Size>& key) { |
| 203 | const std::string yuzu_keys_dir = FileUtil::GetUserPath(FileUtil::UserPath::KeysDir); | 203 | const std::string yuzu_keys_dir = FileUtil::GetUserPath(FileUtil::UserPath::KeysDir); |
| 204 | std::string filename = "title.keys_autogenerated"; | 204 | std::string filename = "title.keys_autogenerated"; |
| 205 | if (!title_key) | 205 | if (!title_key) |
| @@ -209,11 +209,10 @@ void KeyManager::WriteKeyToFile(bool title_key, std::string_view keyname, | |||
| 209 | if (!file.is_open()) | 209 | if (!file.is_open()) |
| 210 | return; | 210 | return; |
| 211 | if (add_info_text) { | 211 | if (add_info_text) { |
| 212 | file << "# This file is autogenerated by Yuzu" << std::endl | 212 | file |
| 213 | << "# It serves to store keys that were automatically generated from the normal keys" | 213 | << "# This file is autogenerated by Yuzu\n" |
| 214 | << std::endl | 214 | << "# It serves to store keys that were automatically generated from the normal keys\n" |
| 215 | << "# If you are experiencing issues involving keys, it may help to delete this file" | 215 | << "# If you are experiencing issues involving keys, it may help to delete this file\n"; |
| 216 | << std::endl; | ||
| 217 | } | 216 | } |
| 218 | 217 | ||
| 219 | file << std::endl | 218 | file << std::endl |
| @@ -263,11 +262,12 @@ bool KeyManager::KeyFileExists(bool title) { | |||
| 263 | } | 262 | } |
| 264 | 263 | ||
| 265 | void KeyManager::DeriveSDSeedLazy() { | 264 | void KeyManager::DeriveSDSeedLazy() { |
| 266 | if (!HasKey(S128KeyType::SDSeed)) { | 265 | if (HasKey(S128KeyType::SDSeed)) |
| 267 | const auto res = DeriveSDSeed(); | 266 | return; |
| 268 | if (res != boost::none) | 267 | |
| 269 | SetKey(S128KeyType::SDSeed, res.get()); | 268 | const auto res = DeriveSDSeed(); |
| 270 | } | 269 | if (res != boost::none) |
| 270 | SetKey(S128KeyType::SDSeed, res.get()); | ||
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | const boost::container::flat_map<std::string, KeyIndex<S128KeyType>> KeyManager::s128_file_id = { | 273 | const boost::container::flat_map<std::string, KeyIndex<S128KeyType>> KeyManager::s128_file_id = { |
diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index 78d0b64e0..7a8728f76 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h | |||
| @@ -74,9 +74,7 @@ struct KeyIndex { | |||
| 74 | // boost flat_map requires operator< for O(log(n)) lookups. | 74 | // boost flat_map requires operator< for O(log(n)) lookups. |
| 75 | template <typename KeyType> | 75 | template <typename KeyType> |
| 76 | bool operator<(const KeyIndex<KeyType>& lhs, const KeyIndex<KeyType>& rhs) { | 76 | bool operator<(const KeyIndex<KeyType>& lhs, const KeyIndex<KeyType>& rhs) { |
| 77 | return (static_cast<size_t>(lhs.type) < static_cast<size_t>(rhs.type)) || | 77 | return std::tie(lhs.type, lhs.field1, lhs.field2) < std::tie(rhs.type, rhs.field1, rhs.field2); |
| 78 | (lhs.type == rhs.type && lhs.field1 < rhs.field1) || | ||
| 79 | (lhs.type == rhs.type && lhs.field1 == rhs.field1 && lhs.field2 < rhs.field2); | ||
| 80 | } | 78 | } |
| 81 | 79 | ||
| 82 | class KeyManager { | 80 | class KeyManager { |
| @@ -107,7 +105,7 @@ private: | |||
| 107 | void AttemptLoadKeyFile(const std::string& dir1, const std::string& dir2, | 105 | void AttemptLoadKeyFile(const std::string& dir1, const std::string& dir2, |
| 108 | const std::string& filename, bool title); | 106 | const std::string& filename, bool title); |
| 109 | template <size_t Size> | 107 | template <size_t Size> |
| 110 | void WriteKeyToFile(bool title_key, std::string_view keyname, std::array<u8, Size> key); | 108 | void WriteKeyToFile(bool title_key, std::string_view keyname, const std::array<u8, Size>& key); |
| 111 | 109 | ||
| 112 | static const boost::container::flat_map<std::string, KeyIndex<S128KeyType>> s128_file_id; | 110 | static const boost::container::flat_map<std::string, KeyIndex<S128KeyType>> s128_file_id; |
| 113 | static const boost::container::flat_map<std::string, KeyIndex<S256KeyType>> s256_file_id; | 111 | static const boost::container::flat_map<std::string, KeyIndex<S256KeyType>> s256_file_id; |
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index a128fa33d..a02efc71e 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp | |||
| @@ -254,6 +254,8 @@ RegisteredCache::RegisteredCache(VirtualDir dir_, RegisteredCacheParsingFunction | |||
| 254 | Refresh(); | 254 | Refresh(); |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | RegisteredCache::~RegisteredCache() = default; | ||
| 258 | |||
| 257 | bool RegisteredCache::HasEntry(u64 title_id, ContentRecordType type) const { | 259 | bool RegisteredCache::HasEntry(u64 title_id, ContentRecordType type) const { |
| 258 | return GetEntryRaw(title_id, type) != nullptr; | 260 | return GetEntryRaw(title_id, type) != nullptr; |
| 259 | } | 261 | } |
diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index f48cf3146..7b8955dfa 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h | |||
| @@ -63,6 +63,7 @@ public: | |||
| 63 | explicit RegisteredCache(VirtualDir dir, | 63 | explicit RegisteredCache(VirtualDir dir, |
| 64 | RegisteredCacheParsingFunction parsing_function = | 64 | RegisteredCacheParsingFunction parsing_function = |
| 65 | [](const VirtualFile& file, const NcaID& id) { return file; }); | 65 | [](const VirtualFile& file, const NcaID& id) { return file; }); |
| 66 | ~RegisteredCache(); | ||
| 66 | 67 | ||
| 67 | void Refresh(); | 68 | void Refresh(); |
| 68 | 69 | ||
diff --git a/src/core/file_sys/sdmc_factory.h b/src/core/file_sys/sdmc_factory.h index bb579472c..4eac92621 100644 --- a/src/core/file_sys/sdmc_factory.h +++ b/src/core/file_sys/sdmc_factory.h | |||
| @@ -4,11 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | ||
| 7 | #include "core/file_sys/vfs.h" | 8 | #include "core/file_sys/vfs.h" |
| 8 | #include "core/hle/result.h" | 9 | #include "core/hle/result.h" |
| 9 | 10 | ||
| 10 | namespace FileSys { | 11 | namespace FileSys { |
| 11 | 12 | ||
| 13 | class RegisteredCache; | ||
| 14 | |||
| 12 | /// File system interface to the SDCard archive | 15 | /// File system interface to the SDCard archive |
| 13 | class SDMCFactory { | 16 | class SDMCFactory { |
| 14 | public: | 17 | public: |
diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp index 76390bf46..b35fdc3f8 100644 --- a/src/core/loader/nax.cpp +++ b/src/core/loader/nax.cpp | |||
| @@ -6,8 +6,10 @@ | |||
| 6 | #include "core/core.h" | 6 | #include "core/core.h" |
| 7 | #include "core/file_sys/content_archive.h" | 7 | #include "core/file_sys/content_archive.h" |
| 8 | #include "core/file_sys/romfs.h" | 8 | #include "core/file_sys/romfs.h" |
| 9 | #include "core/file_sys/xts_archive.h" | ||
| 9 | #include "core/hle/kernel/process.h" | 10 | #include "core/hle/kernel/process.h" |
| 10 | #include "core/loader/nax.h" | 11 | #include "core/loader/nax.h" |
| 12 | #include "core/loader/nca.h" | ||
| 11 | 13 | ||
| 12 | namespace Loader { | 14 | namespace Loader { |
| 13 | 15 | ||
diff --git a/src/core/loader/nax.h b/src/core/loader/nax.h index 08d6ef346..4dbae2918 100644 --- a/src/core/loader/nax.h +++ b/src/core/loader/nax.h | |||
| @@ -6,18 +6,23 @@ | |||
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "core/file_sys/card_image.h" | ||
| 10 | #include "core/file_sys/xts_archive.h" | ||
| 11 | #include "core/loader/loader.h" | 9 | #include "core/loader/loader.h" |
| 12 | #include "core/loader/nca.h" | 10 | |
| 11 | namespace FileSys { | ||
| 12 | |||
| 13 | class NAX; | ||
| 14 | |||
| 15 | } // namespace FileSys | ||
| 13 | 16 | ||
| 14 | namespace Loader { | 17 | namespace Loader { |
| 15 | 18 | ||
| 19 | class AppLoader_NCA; | ||
| 20 | |||
| 16 | /// Loads a NAX file | 21 | /// Loads a NAX file |
| 17 | class AppLoader_NAX final : public AppLoader { | 22 | class AppLoader_NAX final : public AppLoader { |
| 18 | public: | 23 | public: |
| 19 | explicit AppLoader_NAX(FileSys::VirtualFile file); | 24 | explicit AppLoader_NAX(FileSys::VirtualFile file); |
| 20 | ~AppLoader_NAX(); | 25 | ~AppLoader_NAX() override; |
| 21 | 26 | ||
| 22 | /** | 27 | /** |
| 23 | * Returns the type of the file | 28 | * Returns the type of the file |