summaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-07-29 19:00:09 -0400
committerGravatar Zach Hilman2018-08-01 00:16:54 -0400
commit03149d3e4a7f8038d9c88cbeb19dee25a39e0042 (patch)
treecae04a5eefd883d1a665d9502370ec5ff9faa3fd /src/core/file_sys
parentAllow key loading from %YUZU_DIR%/keys in addition to ~/.switch (diff)
downloadyuzu-03149d3e4a7f8038d9c88cbeb19dee25a39e0042.tar.gz
yuzu-03149d3e4a7f8038d9c88cbeb19dee25a39e0042.tar.xz
yuzu-03149d3e4a7f8038d9c88cbeb19dee25a39e0042.zip
Add missing includes and use const where applicable
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/card_image.cpp5
-rw-r--r--src/core/file_sys/card_image.h3
-rw-r--r--src/core/file_sys/content_archive.cpp4
-rw-r--r--src/core/file_sys/content_archive.h11
4 files changed, 14 insertions, 9 deletions
diff --git a/src/core/file_sys/card_image.cpp b/src/core/file_sys/card_image.cpp
index 3c1dbf46c..c69812455 100644
--- a/src/core/file_sys/card_image.cpp
+++ b/src/core/file_sys/card_image.cpp
@@ -93,8 +93,9 @@ VirtualDir XCI::GetLogoPartition() const {
93} 93}
94 94
95std::shared_ptr<NCA> XCI::GetNCAByType(NCAContentType type) const { 95std::shared_ptr<NCA> XCI::GetNCAByType(NCAContentType type) const {
96 auto iter = std::find_if(ncas.begin(), ncas.end(), 96 const auto iter =
97 [type](std::shared_ptr<NCA> nca) { return nca->GetType() == type; }); 97 std::find_if(ncas.begin(), ncas.end(),
98 [type](const std::shared_ptr<NCA>& nca) { return nca->GetType() == type; });
98 return iter == ncas.end() ? nullptr : *iter; 99 return iter == ncas.end() ? nullptr : *iter;
99} 100}
100 101
diff --git a/src/core/file_sys/card_image.h b/src/core/file_sys/card_image.h
index b765c8bc1..e089d737c 100644
--- a/src/core/file_sys/card_image.h
+++ b/src/core/file_sys/card_image.h
@@ -4,10 +4,13 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
7#include <vector> 8#include <vector>
9#include "common/common_types.h"
8#include "common/swap.h" 10#include "common/swap.h"
9#include "core/file_sys/content_archive.h" 11#include "core/file_sys/content_archive.h"
10#include "core/file_sys/vfs.h" 12#include "core/file_sys/vfs.h"
13#include "core/loader/loader.h"
11 14
12namespace FileSys { 15namespace FileSys {
13 16
diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp
index 952dc7068..9eceaa4c4 100644
--- a/src/core/file_sys/content_archive.cpp
+++ b/src/core/file_sys/content_archive.cpp
@@ -76,7 +76,7 @@ bool IsValidNCA(const NCAHeader& header) {
76 return header.magic == Common::MakeMagic('N', 'C', 'A', '3'); 76 return header.magic == Common::MakeMagic('N', 'C', 'A', '3');
77} 77}
78 78
79Core::Crypto::Key128 NCA::GetKeyAreaKey(NCASectionCryptoType type) { 79Core::Crypto::Key128 NCA::GetKeyAreaKey(NCASectionCryptoType type) const {
80 u8 master_key_id = header.crypto_type; 80 u8 master_key_id = header.crypto_type;
81 if (header.crypto_type_2 > master_key_id) 81 if (header.crypto_type_2 > master_key_id)
82 master_key_id = header.crypto_type_2; 82 master_key_id = header.crypto_type_2;
@@ -105,7 +105,7 @@ Core::Crypto::Key128 NCA::GetKeyAreaKey(NCASectionCryptoType type) {
105 return out; 105 return out;
106} 106}
107 107
108VirtualFile NCA::Decrypt(NCASectionHeader header, VirtualFile in, u64 starting_offset) { 108VirtualFile NCA::Decrypt(NCASectionHeader header, VirtualFile in, u64 starting_offset) const {
109 if (!encrypted) 109 if (!encrypted)
110 return in; 110 return in;
111 111
diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h
index 153142b06..e68ab0235 100644
--- a/src/core/file_sys/content_archive.h
+++ b/src/core/file_sys/content_archive.h
@@ -17,6 +17,9 @@
17#include "core/loader/loader.h" 17#include "core/loader/loader.h"
18 18
19namespace FileSys { 19namespace FileSys {
20
21union NCASectionHeader;
22
20enum class NCAContentType : u8 { 23enum class NCAContentType : u8 {
21 Program = 0, 24 Program = 0,
22 Meta = 1, 25 Meta = 1,
@@ -61,8 +64,6 @@ struct NCAHeader {
61}; 64};
62static_assert(sizeof(NCAHeader) == 0x400, "NCAHeader has incorrect size."); 65static_assert(sizeof(NCAHeader) == 0x400, "NCAHeader has incorrect size.");
63 66
64union NCASectionHeader;
65
66inline bool IsDirectoryExeFS(const std::shared_ptr<VfsDirectory>& pfs) { 67inline bool IsDirectoryExeFS(const std::shared_ptr<VfsDirectory>& pfs) {
67 // According to switchbrew, an exefs must only contain these two files: 68 // According to switchbrew, an exefs must only contain these two files:
68 return pfs->GetFile("main") != nullptr && pfs->GetFile("main.npdm") != nullptr; 69 return pfs->GetFile("main") != nullptr && pfs->GetFile("main.npdm") != nullptr;
@@ -94,6 +95,9 @@ protected:
94 bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override; 95 bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override;
95 96
96private: 97private:
98 Core::Crypto::Key128 GetKeyAreaKey(NCASectionCryptoType type) const;
99 VirtualFile Decrypt(NCASectionHeader header, VirtualFile in, u64 starting_offset) const;
100
97 std::vector<VirtualDir> dirs; 101 std::vector<VirtualDir> dirs;
98 std::vector<VirtualFile> files; 102 std::vector<VirtualFile> files;
99 103
@@ -108,9 +112,6 @@ private:
108 bool encrypted; 112 bool encrypted;
109 113
110 Core::Crypto::KeyManager keys; 114 Core::Crypto::KeyManager keys;
111 Core::Crypto::Key128 GetKeyAreaKey(NCASectionCryptoType type);
112
113 VirtualFile Decrypt(NCASectionHeader header, VirtualFile in, u64 starting_offset);
114}; 115};
115 116
116} // namespace FileSys 117} // namespace FileSys