file_sys: Cut down on includes and copies
This commit is contained in:
parent
42dc856ce1
commit
a7e8d10969
7 changed files with 30 additions and 19 deletions
|
@ -199,7 +199,7 @@ Key256 KeyManager::GetKey(S256KeyType id, u64 field1, u64 field2) const {
|
||||||
|
|
||||||
template <size_t Size>
|
template <size_t Size>
|
||||||
void KeyManager::WriteKeyToFile(bool title_key, std::string_view keyname,
|
void KeyManager::WriteKeyToFile(bool title_key, std::string_view keyname,
|
||||||
std::array<u8, Size> key) {
|
const std::array<u8, Size>& key) {
|
||||||
const std::string yuzu_keys_dir = FileUtil::GetUserPath(FileUtil::UserPath::KeysDir);
|
const std::string yuzu_keys_dir = FileUtil::GetUserPath(FileUtil::UserPath::KeysDir);
|
||||||
std::string filename = "title.keys_autogenerated";
|
std::string filename = "title.keys_autogenerated";
|
||||||
if (!title_key)
|
if (!title_key)
|
||||||
|
@ -209,11 +209,10 @@ void KeyManager::WriteKeyToFile(bool title_key, std::string_view keyname,
|
||||||
if (!file.is_open())
|
if (!file.is_open())
|
||||||
return;
|
return;
|
||||||
if (add_info_text) {
|
if (add_info_text) {
|
||||||
file << "# This file is autogenerated by Yuzu" << std::endl
|
file
|
||||||
<< "# It serves to store keys that were automatically generated from the normal keys"
|
<< "# This file is autogenerated by Yuzu\n"
|
||||||
<< std::endl
|
<< "# It serves to store keys that were automatically generated from the normal keys\n"
|
||||||
<< "# If you are experiencing issues involving keys, it may help to delete this file"
|
<< "# If you are experiencing issues involving keys, it may help to delete this file\n";
|
||||||
<< std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file << std::endl
|
file << std::endl
|
||||||
|
@ -263,11 +262,12 @@ bool KeyManager::KeyFileExists(bool title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyManager::DeriveSDSeedLazy() {
|
void KeyManager::DeriveSDSeedLazy() {
|
||||||
if (!HasKey(S128KeyType::SDSeed)) {
|
if (HasKey(S128KeyType::SDSeed))
|
||||||
|
return;
|
||||||
|
|
||||||
const auto res = DeriveSDSeed();
|
const auto res = DeriveSDSeed();
|
||||||
if (res != boost::none)
|
if (res != boost::none)
|
||||||
SetKey(S128KeyType::SDSeed, res.get());
|
SetKey(S128KeyType::SDSeed, res.get());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const boost::container::flat_map<std::string, KeyIndex<S128KeyType>> KeyManager::s128_file_id = {
|
const boost::container::flat_map<std::string, KeyIndex<S128KeyType>> KeyManager::s128_file_id = {
|
||||||
|
|
|
@ -74,9 +74,7 @@ struct KeyIndex {
|
||||||
// boost flat_map requires operator< for O(log(n)) lookups.
|
// boost flat_map requires operator< for O(log(n)) lookups.
|
||||||
template <typename KeyType>
|
template <typename KeyType>
|
||||||
bool operator<(const KeyIndex<KeyType>& lhs, const KeyIndex<KeyType>& rhs) {
|
bool operator<(const KeyIndex<KeyType>& lhs, const KeyIndex<KeyType>& rhs) {
|
||||||
return (static_cast<size_t>(lhs.type) < static_cast<size_t>(rhs.type)) ||
|
return std::tie(lhs.type, lhs.field1, lhs.field2) < std::tie(rhs.type, rhs.field1, rhs.field2);
|
||||||
(lhs.type == rhs.type && lhs.field1 < rhs.field1) ||
|
|
||||||
(lhs.type == rhs.type && lhs.field1 == rhs.field1 && lhs.field2 < rhs.field2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class KeyManager {
|
class KeyManager {
|
||||||
|
@ -107,7 +105,7 @@ private:
|
||||||
void AttemptLoadKeyFile(const std::string& dir1, const std::string& dir2,
|
void AttemptLoadKeyFile(const std::string& dir1, const std::string& dir2,
|
||||||
const std::string& filename, bool title);
|
const std::string& filename, bool title);
|
||||||
template <size_t Size>
|
template <size_t Size>
|
||||||
void WriteKeyToFile(bool title_key, std::string_view keyname, std::array<u8, Size> key);
|
void WriteKeyToFile(bool title_key, std::string_view keyname, const std::array<u8, Size>& key);
|
||||||
|
|
||||||
static const boost::container::flat_map<std::string, KeyIndex<S128KeyType>> s128_file_id;
|
static const boost::container::flat_map<std::string, KeyIndex<S128KeyType>> s128_file_id;
|
||||||
static const boost::container::flat_map<std::string, KeyIndex<S256KeyType>> s256_file_id;
|
static const boost::container::flat_map<std::string, KeyIndex<S256KeyType>> s256_file_id;
|
||||||
|
|
|
@ -254,6 +254,8 @@ RegisteredCache::RegisteredCache(VirtualDir dir_, RegisteredCacheParsingFunction
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RegisteredCache::~RegisteredCache() = default;
|
||||||
|
|
||||||
bool RegisteredCache::HasEntry(u64 title_id, ContentRecordType type) const {
|
bool RegisteredCache::HasEntry(u64 title_id, ContentRecordType type) const {
|
||||||
return GetEntryRaw(title_id, type) != nullptr;
|
return GetEntryRaw(title_id, type) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
explicit RegisteredCache(VirtualDir dir,
|
explicit RegisteredCache(VirtualDir dir,
|
||||||
RegisteredCacheParsingFunction parsing_function =
|
RegisteredCacheParsingFunction parsing_function =
|
||||||
[](const VirtualFile& file, const NcaID& id) { return file; });
|
[](const VirtualFile& file, const NcaID& id) { return file; });
|
||||||
|
~RegisteredCache();
|
||||||
|
|
||||||
void Refresh();
|
void Refresh();
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include "core/file_sys/vfs.h"
|
#include "core/file_sys/vfs.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
|
||||||
|
class RegisteredCache;
|
||||||
|
|
||||||
/// File system interface to the SDCard archive
|
/// File system interface to the SDCard archive
|
||||||
class SDMCFactory {
|
class SDMCFactory {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -6,8 +6,10 @@
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/file_sys/content_archive.h"
|
#include "core/file_sys/content_archive.h"
|
||||||
#include "core/file_sys/romfs.h"
|
#include "core/file_sys/romfs.h"
|
||||||
|
#include "core/file_sys/xts_archive.h"
|
||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
#include "core/loader/nax.h"
|
#include "core/loader/nax.h"
|
||||||
|
#include "core/loader/nca.h"
|
||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
|
||||||
|
|
|
@ -6,18 +6,23 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/file_sys/card_image.h"
|
|
||||||
#include "core/file_sys/xts_archive.h"
|
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
#include "core/loader/nca.h"
|
|
||||||
|
namespace FileSys {
|
||||||
|
|
||||||
|
class NAX;
|
||||||
|
|
||||||
|
} // namespace FileSys
|
||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
|
||||||
|
class AppLoader_NCA;
|
||||||
|
|
||||||
/// Loads a NAX file
|
/// Loads a NAX file
|
||||||
class AppLoader_NAX final : public AppLoader {
|
class AppLoader_NAX final : public AppLoader {
|
||||||
public:
|
public:
|
||||||
explicit AppLoader_NAX(FileSys::VirtualFile file);
|
explicit AppLoader_NAX(FileSys::VirtualFile file);
|
||||||
~AppLoader_NAX();
|
~AppLoader_NAX() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type of the file
|
* Returns the type of the file
|
||||||
|
|
Loading…
Reference in a new issue