Add missing includes and use const where applicable

This commit is contained in:
Zach Hilman 2018-07-29 19:00:09 -04:00
parent 150527ec19
commit 03149d3e4a
11 changed files with 40 additions and 24 deletions

View file

@ -93,8 +93,9 @@ VirtualDir XCI::GetLogoPartition() const {
}
std::shared_ptr<NCA> XCI::GetNCAByType(NCAContentType type) const {
auto iter = std::find_if(ncas.begin(), ncas.end(),
[type](std::shared_ptr<NCA> nca) { return nca->GetType() == type; });
const auto iter =
std::find_if(ncas.begin(), ncas.end(),
[type](const std::shared_ptr<NCA>& nca) { return nca->GetType() == type; });
return iter == ncas.end() ? nullptr : *iter;
}

View file

@ -4,10 +4,13 @@
#pragma once
#include <array>
#include <vector>
#include "common/common_types.h"
#include "common/swap.h"
#include "core/file_sys/content_archive.h"
#include "core/file_sys/vfs.h"
#include "core/loader/loader.h"
namespace FileSys {

View file

@ -76,7 +76,7 @@ bool IsValidNCA(const NCAHeader& header) {
return header.magic == Common::MakeMagic('N', 'C', 'A', '3');
}
Core::Crypto::Key128 NCA::GetKeyAreaKey(NCASectionCryptoType type) {
Core::Crypto::Key128 NCA::GetKeyAreaKey(NCASectionCryptoType type) const {
u8 master_key_id = header.crypto_type;
if (header.crypto_type_2 > master_key_id)
master_key_id = header.crypto_type_2;
@ -105,7 +105,7 @@ Core::Crypto::Key128 NCA::GetKeyAreaKey(NCASectionCryptoType type) {
return out;
}
VirtualFile NCA::Decrypt(NCASectionHeader header, VirtualFile in, u64 starting_offset) {
VirtualFile NCA::Decrypt(NCASectionHeader header, VirtualFile in, u64 starting_offset) const {
if (!encrypted)
return in;

View file

@ -17,6 +17,9 @@
#include "core/loader/loader.h"
namespace FileSys {
union NCASectionHeader;
enum class NCAContentType : u8 {
Program = 0,
Meta = 1,
@ -61,8 +64,6 @@ struct NCAHeader {
};
static_assert(sizeof(NCAHeader) == 0x400, "NCAHeader has incorrect size.");
union NCASectionHeader;
inline bool IsDirectoryExeFS(const std::shared_ptr<VfsDirectory>& pfs) {
// According to switchbrew, an exefs must only contain these two files:
return pfs->GetFile("main") != nullptr && pfs->GetFile("main.npdm") != nullptr;
@ -94,6 +95,9 @@ protected:
bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override;
private:
Core::Crypto::Key128 GetKeyAreaKey(NCASectionCryptoType type) const;
VirtualFile Decrypt(NCASectionHeader header, VirtualFile in, u64 starting_offset) const;
std::vector<VirtualDir> dirs;
std::vector<VirtualFile> files;
@ -108,9 +112,6 @@ private:
bool encrypted;
Core::Crypto::KeyManager keys;
Core::Crypto::Key128 GetKeyAreaKey(NCASectionCryptoType type);
VirtualFile Decrypt(NCASectionHeader header, VirtualFile in, u64 starting_offset);
};
} // namespace FileSys