strat: use m_ for member variables

This commit is contained in:
Michael Scire
2021-10-10 00:14:06 -07:00
parent ce28591ab2
commit a595c232b9
425 changed files with 8531 additions and 8484 deletions

View File

@@ -80,7 +80,7 @@ namespace ams::ncm {
ncm::ContentMetaReader meta_reader(meta.get(), meta_size);
/* Insert the new metas into the database. */
R_TRY(this->db->Set(package_meta_reader.GetKey(), meta_reader.GetData(), meta_reader.GetSize()));
R_TRY(m_db->Set(package_meta_reader.GetKey(), meta_reader.GetData(), meta_reader.GetSize()));
/* We're done. */
return ResultSuccess();
@@ -123,7 +123,7 @@ namespace ams::ncm {
}
/* Commit our changes. */
return this->db->Commit();
return m_db->Commit();
}
Result ContentMetaDatabaseBuilder::BuildFromPackage(const char *package_root_path) {
@@ -148,7 +148,7 @@ namespace ams::ncm {
}));
/* Commit our changes. */
return this->db->Commit();
return m_db->Commit();
}
Result ContentMetaDatabaseBuilder::Cleanup() {
@@ -157,11 +157,11 @@ namespace ams::ncm {
/* List as many keys as we can. */
constexpr s32 MaxKeys = 64;
ContentMetaKey keys[MaxKeys];
auto list_count = this->db->ListContentMeta(keys, MaxKeys);
auto list_count = m_db->ListContentMeta(keys, MaxKeys);
/* Remove the listed keys. */
for (auto i = 0; i < list_count.written; i++) {
R_TRY(this->db->Remove(keys[i]));
R_TRY(m_db->Remove(keys[i]));
}
/* If there aren't more keys to read, we're done. */
@@ -171,7 +171,7 @@ namespace ams::ncm {
}
/* Commit our deletions. */
return this->db->Commit();
return m_db->Commit();
}
Result ListApplicationPackage(s32 *out_count, ApplicationId *out_ids, size_t max_out_ids, const char *package_root_path) {

View File

@@ -133,15 +133,15 @@ namespace ams::ncm {
}
ContentManagerImpl::~ContentManagerImpl() {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Disable and unmount all content storage roots. */
for (auto &root : this->content_storage_roots) {
for (auto &root : m_content_storage_roots) {
this->InactivateContentStorage(root.storage_id);
}
/* Disable and unmount all content meta database roots. */
for (auto &root : this->content_meta_database_roots) {
for (auto &root : m_content_meta_database_roots) {
this->InactivateContentMetaDatabase(root.storage_id);
}
}
@@ -171,7 +171,7 @@ namespace ams::ncm {
R_UNLESS(IsUniqueStorage(id), ncm::ResultUnknownStorage());
/* Find a root with a matching storage id. */
for (auto &root : this->content_storage_roots) {
for (auto &root : m_content_storage_roots) {
if (root.storage_id == id) {
*out = std::addressof(root);
return ResultSuccess();
@@ -186,7 +186,7 @@ namespace ams::ncm {
R_UNLESS(IsUniqueStorage(id), ncm::ResultUnknownStorage());
/* Find a root with a matching storage id. */
for (auto &root : this->content_meta_database_roots) {
for (auto &root : m_content_meta_database_roots) {
if (root.storage_id == id) {
*out = std::addressof(root);
return ResultSuccess();
@@ -247,7 +247,7 @@ namespace ams::ncm {
}
Result ContentManagerImpl::ImportContentMetaDatabaseImpl(StorageId storage_id, const char *import_mount_name, const char *path) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
@@ -316,29 +316,29 @@ namespace ams::ncm {
}
Result ContentManagerImpl::Initialize(const ContentManagerConfig &config) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Check if we've already initialized. */
R_SUCCEED_IF(this->initialized);
R_SUCCEED_IF(m_initialized);
/* Clear storage id for all roots. */
for (auto &root : this->content_storage_roots) {
for (auto &root : m_content_storage_roots) {
root.storage_id = StorageId::None;
}
for (auto &root : this->content_meta_database_roots) {
for (auto &root : m_content_meta_database_roots) {
root.storage_id = StorageId::None;
}
/* First, setup the BuiltInSystem storage entry. */
R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[this->num_content_storage_entries++]), StorageId::BuiltInSystem, fs::ContentStorageId::System));
R_TRY(this->InitializeContentStorageRoot(std::addressof(m_content_storage_roots[m_num_content_storage_entries++]), StorageId::BuiltInSystem, fs::ContentStorageId::System));
if (R_FAILED(this->VerifyContentStorage(StorageId::BuiltInSystem))) {
R_TRY(this->CreateContentStorage(StorageId::BuiltInSystem));
}
R_TRY(this->ActivateContentStorage(StorageId::BuiltInSystem));
/* Next, the BuiltInSystem content meta entry. */
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[this->num_content_meta_entries++]), StorageId::BuiltInSystem, BuiltInSystemSystemSaveDataInfo, SystemMaxContentMetaCount, std::addressof(g_system_content_meta_memory_resource)));
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(m_content_meta_database_roots[m_num_content_meta_entries++]), StorageId::BuiltInSystem, BuiltInSystemSystemSaveDataInfo, SystemMaxContentMetaCount, std::addressof(g_system_content_meta_memory_resource)));
if (R_FAILED(this->VerifyContentMetaDatabase(StorageId::BuiltInSystem))) {
R_TRY(this->CreateContentMetaDatabase(StorageId::BuiltInSystem));
@@ -365,26 +365,26 @@ namespace ams::ncm {
R_TRY(this->ActivateContentMetaDatabase(StorageId::BuiltInSystem));
/* Now for BuiltInUser's content storage and content meta entries. */
R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[this->num_content_storage_entries++]), StorageId::BuiltInUser, fs::ContentStorageId::User));
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[this->num_content_meta_entries++]), StorageId::BuiltInUser, BuiltInUserSystemSaveDataInfo, UserMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
R_TRY(this->InitializeContentStorageRoot(std::addressof(m_content_storage_roots[m_num_content_storage_entries++]), StorageId::BuiltInUser, fs::ContentStorageId::User));
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(m_content_meta_database_roots[m_num_content_meta_entries++]), StorageId::BuiltInUser, BuiltInUserSystemSaveDataInfo, UserMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
/* Beyond this point, N uses hardcoded indices. */
/* Next SdCard's content storage and content meta entries. */
R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[2]), StorageId::SdCard, fs::ContentStorageId::SdCard));
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[2]), StorageId::SdCard, SdCardSystemSaveDataInfo, SdCardMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
R_TRY(this->InitializeContentStorageRoot(std::addressof(m_content_storage_roots[2]), StorageId::SdCard, fs::ContentStorageId::SdCard));
R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(m_content_meta_database_roots[2]), StorageId::SdCard, SdCardSystemSaveDataInfo, SdCardMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource)));
/* GameCard's content storage and content meta entries. */
/* N doesn't set a content storage id for game cards, so we'll just use 0 (System). */
R_TRY(this->InitializeGameCardContentStorageRoot(std::addressof(this->content_storage_roots[3])));
R_TRY(this->InitializeGameCardContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[3]), GameCardMaxContentMetaCount, std::addressof(g_gamecard_content_meta_memory_resource)));
R_TRY(this->InitializeGameCardContentStorageRoot(std::addressof(m_content_storage_roots[3])));
R_TRY(this->InitializeGameCardContentMetaDatabaseRoot(std::addressof(m_content_meta_database_roots[3]), GameCardMaxContentMetaCount, std::addressof(g_gamecard_content_meta_memory_resource)));
this->initialized = true;
m_initialized = true;
return ResultSuccess();
}
Result ContentManagerImpl::CreateContentStorage(StorageId storage_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Obtain the content storage root. */
ContentStorageRoot *root;
@@ -402,7 +402,7 @@ namespace ams::ncm {
}
Result ContentManagerImpl::CreateContentMetaDatabase(StorageId storage_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
R_UNLESS(storage_id != StorageId::GameCard, ncm::ResultUnknownStorage());
@@ -422,7 +422,7 @@ namespace ams::ncm {
}
Result ContentManagerImpl::VerifyContentStorage(StorageId storage_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Obtain the content storage root. */
ContentStorageRoot *root;
@@ -445,7 +445,7 @@ namespace ams::ncm {
/* Game card content meta databases will always be valid. */
R_SUCCEED_IF(storage_id == StorageId::GameCard);
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
@@ -467,7 +467,7 @@ namespace ams::ncm {
}
Result ContentManagerImpl::OpenContentStorage(sf::Out<sf::SharedPointer<IContentStorage>> out, StorageId storage_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Obtain the content storage root. */
ContentStorageRoot *root;
@@ -488,7 +488,7 @@ namespace ams::ncm {
}
Result ContentManagerImpl::OpenContentMetaDatabase(sf::Out<sf::SharedPointer<IContentMetaDatabase>> out, StorageId storage_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
@@ -517,7 +517,7 @@ namespace ams::ncm {
}
Result ContentManagerImpl::CleanupContentMetaDatabase(StorageId storage_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Disable and unmount content meta database root. */
R_TRY(this->InactivateContentMetaDatabase(storage_id));
@@ -531,7 +531,7 @@ namespace ams::ncm {
}
Result ContentManagerImpl::ActivateContentStorage(StorageId storage_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Obtain the content storage root. */
ContentStorageRoot *root;
@@ -554,7 +554,7 @@ namespace ams::ncm {
if (storage_id == StorageId::Host) {
/* Create a host content storage. */
auto content_storage = sf::CreateSharedObjectEmplaced<IContentStorage, HostContentStorageImpl>(std::addressof(this->registered_host_content));
auto content_storage = sf::CreateSharedObjectEmplaced<IContentStorage, HostContentStorageImpl>(std::addressof(m_registered_host_content));
root->content_storage = std::move(content_storage);
} else if (storage_id == StorageId::GameCard) {
/* Game card content storage is read only. */
@@ -568,13 +568,13 @@ namespace ams::ncm {
/* Initialize content storage with an appropriate path function. */
switch (storage_id) {
case StorageId::BuiltInSystem:
R_TRY(content_storage.GetImpl().Initialize(root->path, MakeFlatContentFilePath, MakeFlatPlaceHolderFilePath, false, std::addressof(this->rights_id_cache)));
R_TRY(content_storage.GetImpl().Initialize(root->path, MakeFlatContentFilePath, MakeFlatPlaceHolderFilePath, false, std::addressof(m_rights_id_cache)));
break;
case StorageId::SdCard:
R_TRY(content_storage.GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, true, std::addressof(this->rights_id_cache)));
R_TRY(content_storage.GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, true, std::addressof(m_rights_id_cache)));
break;
default:
R_TRY(content_storage.GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, false, std::addressof(this->rights_id_cache)));
R_TRY(content_storage.GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, false, std::addressof(m_rights_id_cache)));
break;
}
@@ -587,7 +587,7 @@ namespace ams::ncm {
}
Result ContentManagerImpl::InactivateContentStorage(StorageId storage_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Obtain the content storage root. */
ContentStorageRoot *root;
@@ -600,7 +600,7 @@ namespace ams::ncm {
root->content_storage = nullptr;
if (storage_id == StorageId::Host) {
this->registered_host_content.ClearPaths();
m_registered_host_content.ClearPaths();
} else {
fs::Unmount(root->mount_name);
}
@@ -610,7 +610,7 @@ namespace ams::ncm {
}
Result ContentManagerImpl::ActivateContentMetaDatabase(StorageId storage_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
@@ -648,7 +648,7 @@ namespace ams::ncm {
}
Result ContentManagerImpl::InactivateContentMetaDatabase(StorageId storage_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Obtain the content meta database root. */
ContentMetaDatabaseRoot *root;
@@ -671,7 +671,7 @@ namespace ams::ncm {
}
Result ContentManagerImpl::InvalidateRightsIdCache() {
this->rights_id_cache.Invalidate();
m_rights_id_cache.Invalidate();
return ResultSuccess();
}

View File

@@ -22,8 +22,8 @@ namespace ams::ncm {
R_TRY(this->EnsureEnabled());
/* Find the meta key. */
const auto it = this->kvs->lower_bound(key);
R_UNLESS(it != this->kvs->end(), ncm::ResultContentMetaNotFound());
const auto it = m_kvs->lower_bound(key);
R_UNLESS(it != m_kvs->end(), ncm::ResultContentMetaNotFound());
R_UNLESS(it->GetKey().id == key.id, ncm::ResultContentMetaNotFound());
const auto found_key = it->GetKey();
@@ -51,7 +51,7 @@ namespace ams::ncm {
Result ContentMetaDatabaseImpl::Set(const ContentMetaKey &key, const sf::InBuffer &value) {
R_TRY(this->EnsureEnabled());
return this->kvs->Set(key, value.GetPointer(), value.GetSize());
return m_kvs->Set(key, value.GetPointer(), value.GetSize());
}
Result ContentMetaDatabaseImpl::Get(sf::Out<u64> out_size, const ContentMetaKey &key, const sf::OutBuffer &out_value) {
@@ -59,7 +59,7 @@ namespace ams::ncm {
/* Get the entry from our key-value store. */
size_t size;
R_TRY_CATCH(this->kvs->Get(std::addressof(size), out_value.GetPointer(), out_value.GetSize(), key)) {
R_TRY_CATCH(m_kvs->Get(std::addressof(size), out_value.GetPointer(), out_value.GetSize(), key)) {
R_CONVERT(kvdb::ResultKeyNotFound, ncm::ResultContentMetaNotFound())
} R_END_TRY_CATCH;
@@ -70,7 +70,7 @@ namespace ams::ncm {
Result ContentMetaDatabaseImpl::Remove(const ContentMetaKey &key) {
R_TRY(this->EnsureEnabled());
R_TRY_CATCH(this->kvs->Remove(key)) {
R_TRY_CATCH(m_kvs->Remove(key)) {
R_CONVERT(kvdb::ResultKeyNotFound, ncm::ResultContentMetaNotFound())
} R_END_TRY_CATCH;
@@ -110,7 +110,7 @@ namespace ams::ncm {
size_t entries_written = 0;
/* Iterate over all entries. */
for (auto &entry : *this->kvs) {
for (auto &entry : *m_kvs) {
const ContentMetaKey key = entry.GetKey();
/* Check if this entry matches the given filters. */
@@ -152,7 +152,7 @@ namespace ams::ncm {
util::optional<ContentMetaKey> found_key = util::nullopt;
/* Find the last key with the desired program id. */
for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) {
for (auto entry = m_kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != m_kvs->end(); entry++) {
/* No further entries will match the program id, discontinue. */
if (entry->GetKey().id != id) {
break;
@@ -178,7 +178,7 @@ namespace ams::ncm {
size_t entries_written = 0;
/* Iterate over all entries. */
for (auto &entry : *this->kvs) {
for (auto &entry : *m_kvs) {
const ContentMetaKey key = entry.GetKey();
/* Check if this entry matches the given filters. */
@@ -210,7 +210,7 @@ namespace ams::ncm {
/* Check if key is present. */
size_t size;
R_TRY_CATCH(this->kvs->GetValueSize(&size, key)) {
R_TRY_CATCH(m_kvs->GetValueSize(&size, key)) {
R_CONVERT(kvdb::ResultKeyNotFound, ResultSuccess());
} R_END_TRY_CATCH;
@@ -295,7 +295,7 @@ namespace ams::ncm {
}
Result ContentMetaDatabaseImpl::DisableForcibly() {
this->disabled = true;
m_disabled = true;
return ResultSuccess();
}
@@ -320,7 +320,7 @@ namespace ams::ncm {
};
/* Iterate over all entries. */
for (auto &entry : *this->kvs) {
for (auto &entry : *m_kvs) {
ContentMetaReader reader(entry.GetValuePointer(), entry.GetValueSize());
/* Check if any of this entry's content infos matches one of the content ids for lookup. */
@@ -339,8 +339,8 @@ namespace ams::ncm {
R_TRY(this->EnsureEnabled());
/* Save and commit. */
R_TRY(this->kvs->Save());
return fs::CommitSaveData(this->mount_name);
R_TRY(m_kvs->Save());
return fs::CommitSaveData(m_mount_name);
}
Result ContentMetaDatabaseImpl::HasContent(sf::Out<bool> out, const ContentMetaKey &key, const ContentId &content_id) {
@@ -440,7 +440,7 @@ namespace ams::ncm {
Result ContentMetaDatabaseImpl::GetCount(sf::Out<u32> out_count) {
R_TRY(this->EnsureEnabled());
out_count.SetValue(this->kvs->GetCount());
out_count.SetValue(m_kvs->GetCount());
return ResultSuccess();
}

View File

@@ -24,24 +24,24 @@ namespace ams::ncm {
protected:
using ContentMetaKeyValueStore = ams::kvdb::MemoryKeyValueStore<ContentMetaKey>;
protected:
ContentMetaKeyValueStore *kvs;
char mount_name[fs::MountNameLengthMax + 1];
bool disabled;
ContentMetaKeyValueStore *m_kvs;
char m_mount_name[fs::MountNameLengthMax + 1];
bool m_disabled;
protected:
ContentMetaDatabaseImplBase(ContentMetaKeyValueStore *kvs) : kvs(kvs), disabled(false) { /* ... */ }
ContentMetaDatabaseImplBase(ContentMetaKeyValueStore *kvs) : m_kvs(kvs), m_disabled(false) { /* ... */ }
ContentMetaDatabaseImplBase(ContentMetaKeyValueStore *kvs, const char *mount_name) : ContentMetaDatabaseImplBase(kvs) {
std::strcpy(this->mount_name, mount_name);
std::strcpy(m_mount_name, mount_name);
}
protected:
/* Helpers. */
Result EnsureEnabled() const {
R_UNLESS(!this->disabled, ncm::ResultInvalidContentMetaDatabase());
R_UNLESS(!m_disabled, ncm::ResultInvalidContentMetaDatabase());
return ResultSuccess();
}
Result GetContentMetaSize(size_t *out, const ContentMetaKey &key) const {
R_TRY_CATCH(this->kvs->GetValueSize(out, key)) {
R_TRY_CATCH(m_kvs->GetValueSize(out, key)) {
R_CONVERT(kvdb::ResultKeyNotFound, ncm::ResultContentMetaNotFound())
} R_END_TRY_CATCH;
@@ -50,7 +50,7 @@ namespace ams::ncm {
Result GetContentMetaPointer(const void **out_value_ptr, size_t *out_size, const ContentMetaKey &key) const {
R_TRY(this->GetContentMetaSize(out_size, key));
return this->kvs->GetValuePointer(reinterpret_cast<const ContentMetaHeader **>(out_value_ptr), key);
return m_kvs->GetValuePointer(reinterpret_cast<const ContentMetaHeader **>(out_value_ptr), key);
}
public:
/* Actual commands. */

View File

@@ -167,19 +167,19 @@ namespace ams::ncm {
}
ContentStorageImpl::ContentIterator::~ContentIterator() {
for (size_t i = 0; i < this->depth; i++) {
fs::CloseDirectory(this->handles[i]);
for (size_t i = 0; i < m_depth; i++) {
fs::CloseDirectory(m_handles[i]);
}
}
Result ContentStorageImpl::ContentIterator::Initialize(const char *root_path, size_t max_depth) {
/* Initialize tracking variables. */
this->depth = 0;
this->max_depth = max_depth;
this->entry_count = 0;
m_depth = 0;
m_max_depth = max_depth;
m_entry_count = 0;
/* Create the base content directory path. */
MakeBaseContentDirectoryPath(std::addressof(this->path), root_path);
MakeBaseContentDirectoryPath(std::addressof(m_path), root_path);
/* Open the base directory. */
R_TRY(this->OpenCurrentDirectory());
@@ -192,17 +192,17 @@ namespace ams::ncm {
const auto open_mode = hos::GetVersion() >= hos::Version_2_0_0 ? (fs::OpenDirectoryMode_All | fs::OpenDirectoryMode_NotRequireFileSize) : (fs::OpenDirectoryMode_All);
/* Open the directory for our current path. */
R_TRY(fs::OpenDirectory(std::addressof(this->handles[this->depth]), this->path, open_mode));
R_TRY(fs::OpenDirectory(std::addressof(m_handles[m_depth]), m_path, open_mode));
/* Increase our depth. */
++this->depth;
++m_depth;
return ResultSuccess();
}
Result ContentStorageImpl::ContentIterator::OpenDirectory(const char *dir) {
/* Set our current path. */
this->path.Set(dir);
m_path.Set(dir);
/* Open the directory. */
return this->OpenCurrentDirectory();
@@ -215,22 +215,22 @@ namespace ams::ncm {
R_TRY(this->LoadEntries());
/* If we failed to load any entries, there's nothing to get. */
if (this->entry_count <= 0) {
if (m_entry_count <= 0) {
*out = util::nullopt;
return ResultSuccess();
}
/* Get the next entry. */
const auto &entry = this->entries[--this->entry_count];
const auto &entry = m_entries[--m_entry_count];
/* Process the current entry. */
switch (entry.type) {
case fs::DirectoryEntryType_Directory:
/* If the entry if a directory, we want to recurse into it if we can. */
if (this->depth < this->max_depth) {
if (m_depth < m_max_depth) {
/* Construct the full path for the subdirectory. */
PathString entry_path;
entry_path.SetFormat("%s/%s", this->path.Get(), entry.name);
entry_path.SetFormat("%s/%s", m_path.Get(), entry.name);
/* Open the subdirectory. */
R_TRY(this->OpenDirectory(entry_path.Get()));
@@ -250,45 +250,45 @@ namespace ams::ncm {
Result ContentStorageImpl::ContentIterator::LoadEntries() {
/* If we already have entries loaded, we don't need to do anything. */
R_SUCCEED_IF(this->entry_count != 0);
R_SUCCEED_IF(m_entry_count != 0);
/* If we have no directories open, there's nothing for us to load. */
if (this->depth == 0) {
this->entry_count = 0;
if (m_depth == 0) {
m_entry_count = 0;
return ResultSuccess();
}
/* Determine the maximum entries that we can load. */
const s64 max_entries = this->depth == this->max_depth ? MaxDirectoryEntries : 1;
const s64 max_entries = m_depth == m_max_depth ? MaxDirectoryEntries : 1;
/* Read entries from the current directory. */
s64 num_entries;
R_TRY(fs::ReadDirectory(std::addressof(num_entries), this->entries, this->handles[this->depth - 1], max_entries));
R_TRY(fs::ReadDirectory(std::addressof(num_entries), m_entries, m_handles[m_depth - 1], max_entries));
/* If we successfully read entries, load them. */
if (num_entries > 0) {
/* Reverse the order of the loaded entries, for our future convenience. */
for (fs::DirectoryEntry *start_entry = this->entries, *end_entry = this->entries + num_entries - 1; start_entry < end_entry; ++start_entry, --end_entry) {
for (fs::DirectoryEntry *start_entry = m_entries, *end_entry = m_entries + num_entries - 1; start_entry < end_entry; ++start_entry, --end_entry) {
std::swap(*start_entry, *end_entry);
}
/* Set our entry count. */
this->entry_count = num_entries;
m_entry_count = num_entries;
return ResultSuccess();
}
/* We didn't read any entries, so we need to advance to the next directory. */
fs::CloseDirectory(this->handles[--this->depth]);
fs::CloseDirectory(m_handles[--m_depth]);
/* Find the index of the parent directory's substring. */
size_t i = this->path.GetLength() - 1;
while (this->path.Get()[i--] != '/') {
size_t i = m_path.GetLength() - 1;
while (m_path.Get()[i--] != '/') {
AMS_ABORT_UNLESS(i > 0);
}
/* Set the path to the parent directory. */
this->path.Set(this->path.GetSubstring(0, i + 1));
m_path.Set(m_path.GetSubstring(0, i + 1));
/* Try to load again from the parent directory. */
return this->LoadEntries();
@@ -349,30 +349,30 @@ namespace ams::ncm {
}
void ContentStorageImpl::InvalidateFileCache() {
if (this->cached_content_id != InvalidContentId) {
fs::CloseFile(this->cached_file_handle);
this->cached_content_id = InvalidContentId;
if (m_cached_content_id != InvalidContentId) {
fs::CloseFile(m_cached_file_handle);
m_cached_content_id = InvalidContentId;
}
this->content_iterator = util::nullopt;
m_content_iterator = util::nullopt;
}
Result ContentStorageImpl::OpenContentIdFile(ContentId content_id) {
/* If the file is the currently cached one, we've nothing to do. */
R_SUCCEED_IF(this->cached_content_id == content_id);
R_SUCCEED_IF(m_cached_content_id == content_id);
/* Close any cached file. */
this->InvalidateFileCache();
/* Create the content path. */
PathString path;
MakeContentPath(std::addressof(path), content_id, this->make_content_path_func, this->root_path);
MakeContentPath(std::addressof(path), content_id, m_make_content_path_func, m_root_path);
/* Open the content file and store to the cache. */
R_TRY_CATCH(fs::OpenFile(std::addressof(this->cached_file_handle), path, fs::OpenMode_Read)) {
R_TRY_CATCH(fs::OpenFile(std::addressof(m_cached_file_handle), path, fs::OpenMode_Read)) {
R_CONVERT(ams::fs::ResultPathNotFound, ncm::ResultContentNotFound())
} R_END_TRY_CATCH;
this->cached_content_id = content_id;
m_cached_content_id = content_id;
return ResultSuccess();
}
@@ -383,10 +383,10 @@ namespace ams::ncm {
R_TRY(VerifyBase(path));
/* Initialize members. */
this->root_path = PathString(path);
this->make_content_path_func = content_path_func;
this->placeholder_accessor.Initialize(std::addressof(this->root_path), placeholder_path_func, delay_flush);
this->rights_id_cache = rights_id_cache;
m_root_path = PathString(path);
m_make_content_path_func = content_path_func;
m_placeholder_accessor.Initialize(std::addressof(m_root_path), placeholder_path_func, delay_flush);
m_rights_id_cache = rights_id_cache;
return ResultSuccess();
}
@@ -398,13 +398,13 @@ namespace ams::ncm {
Result ContentStorageImpl::CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) {
R_TRY(this->EnsureEnabled());
R_TRY(EnsureContentDirectory(content_id, this->make_content_path_func, this->root_path));
return this->placeholder_accessor.CreatePlaceHolderFile(placeholder_id, size);
R_TRY(EnsureContentDirectory(content_id, m_make_content_path_func, m_root_path));
return m_placeholder_accessor.CreatePlaceHolderFile(placeholder_id, size);
}
Result ContentStorageImpl::DeletePlaceHolder(PlaceHolderId placeholder_id) {
R_TRY(this->EnsureEnabled());
return this->placeholder_accessor.DeletePlaceHolderFile(placeholder_id);
return m_placeholder_accessor.DeletePlaceHolderFile(placeholder_id);
}
Result ContentStorageImpl::HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) {
@@ -412,7 +412,7 @@ namespace ams::ncm {
/* Create the placeholder path. */
PathString placeholder_path;
this->placeholder_accessor.MakePath(std::addressof(placeholder_path), placeholder_id);
m_placeholder_accessor.MakePath(std::addressof(placeholder_path), placeholder_id);
/* Check if placeholder file exists. */
bool has = false;
@@ -425,7 +425,7 @@ namespace ams::ncm {
/* Ensure offset is valid. */
R_UNLESS(offset >= 0, ncm::ResultInvalidOffset());
R_TRY(this->EnsureEnabled());
return this->placeholder_accessor.WritePlaceHolderFile(placeholder_id, offset, data.GetPointer(), data.GetSize());
return m_placeholder_accessor.WritePlaceHolderFile(placeholder_id, offset, data.GetPointer(), data.GetSize());
}
Result ContentStorageImpl::Register(PlaceHolderId placeholder_id, ContentId content_id) {
@@ -434,11 +434,11 @@ namespace ams::ncm {
/* Create the placeholder path. */
PathString placeholder_path;
this->placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id);
m_placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id);
/* Create the content path. */
PathString content_path;
MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path);
MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path);
/* Move the placeholder to the content path. */
R_TRY_CATCH(fs::RenameFile(placeholder_path, content_path)) {
@@ -452,7 +452,7 @@ namespace ams::ncm {
Result ContentStorageImpl::Delete(ContentId content_id) {
R_TRY(this->EnsureEnabled());
this->InvalidateFileCache();
return DeleteContentFile(content_id, this->make_content_path_func, this->root_path);
return DeleteContentFile(content_id, m_make_content_path_func, m_root_path);
}
Result ContentStorageImpl::Has(sf::Out<bool> out, ContentId content_id) {
@@ -460,7 +460,7 @@ namespace ams::ncm {
/* Create the content path. */
PathString content_path;
MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path);
MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path);
/* Check if the content file exists. */
bool has = false;
@@ -474,7 +474,7 @@ namespace ams::ncm {
/* Create the content path. */
PathString content_path;
MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path);
MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path);
/* Substitute our mount name for the common mount name. */
Path common_path;
@@ -489,7 +489,7 @@ namespace ams::ncm {
/* Obtain the placeholder path. */
PathString placeholder_path;
this->placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id);
m_placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id);
/* Substitute our mount name for the common mount name. */
Path common_path;
@@ -503,11 +503,11 @@ namespace ams::ncm {
R_TRY(this->EnsureEnabled());
/* Clear the cache. */
this->placeholder_accessor.InvalidateAll();
m_placeholder_accessor.InvalidateAll();
/* Obtain the placeholder base directory path. */
PathString placeholder_dir;
PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(placeholder_dir), this->root_path);
PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(placeholder_dir), m_root_path);
/* Cleanup the placeholder base directory. */
CleanDirectoryRecursively(placeholder_dir);
@@ -519,13 +519,13 @@ namespace ams::ncm {
/* Obtain the placeholder base directory path. */
PathString placeholder_dir;
PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(placeholder_dir), this->root_path);
PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(placeholder_dir), m_root_path);
const size_t max_entries = out_buf.GetSize();
size_t entry_count = 0;
/* Traverse the placeholder base directory finding valid placeholder files. */
R_TRY(TraverseDirectory(placeholder_dir, placeholder_accessor.GetHierarchicalDirectoryDepth(), [&](bool *should_continue, bool *should_retry_dir_read, const char *current_path, const fs::DirectoryEntry &entry) -> Result {
R_TRY(TraverseDirectory(placeholder_dir, m_placeholder_accessor.GetHierarchicalDirectoryDepth(), [&](bool *should_continue, bool *should_retry_dir_read, const char *current_path, const fs::DirectoryEntry &entry) -> Result {
AMS_UNUSED(current_path);
*should_continue = true;
@@ -554,9 +554,9 @@ namespace ams::ncm {
/* Obtain the content base directory path. */
PathString path;
MakeBaseContentDirectoryPath(std::addressof(path), this->root_path);
MakeBaseContentDirectoryPath(std::addressof(path), m_root_path);
const auto depth = GetHierarchicalContentDirectoryDepth(this->make_content_path_func);
const auto depth = GetHierarchicalContentDirectoryDepth(m_make_content_path_func);
size_t count = 0;
/* Traverse the content base directory finding all files. */
@@ -582,16 +582,16 @@ namespace ams::ncm {
R_UNLESS(offset >= 0, ncm::ResultInvalidOffset());
R_TRY(this->EnsureEnabled());
if (!this->content_iterator.has_value() || !this->last_content_offset.has_value() || this->last_content_offset != offset) {
if (!m_content_iterator.has_value() || !m_last_content_offset.has_value() || m_last_content_offset != offset) {
/* Create and initialize the content cache. */
this->content_iterator.emplace();
R_TRY(this->content_iterator->Initialize(this->root_path, GetHierarchicalContentDirectoryDepth(this->make_content_path_func)));
m_content_iterator.emplace();
R_TRY(m_content_iterator->Initialize(m_root_path, GetHierarchicalContentDirectoryDepth(m_make_content_path_func)));
/* Advance to the desired offset. */
for (auto current_offset = 0; current_offset < offset; /* ... */) {
/* Get the next directory entry. */
util::optional<fs::DirectoryEntry> dir_entry;
R_TRY(this->content_iterator->GetNext(std::addressof(dir_entry)));
R_TRY(m_content_iterator->GetNext(std::addressof(dir_entry)));
/* If we run out of entries before reaching the desired offset, we're done. */
if (!dir_entry) {
@@ -611,7 +611,7 @@ namespace ams::ncm {
while (count < static_cast<s32>(out.GetSize())) {
/* Get the next directory entry. */
util::optional<fs::DirectoryEntry> dir_entry;
R_TRY(this->content_iterator->GetNext(std::addressof(dir_entry)));
R_TRY(m_content_iterator->GetNext(std::addressof(dir_entry)));
/* Don't continue if the directory entry is absent. */
if (!dir_entry) {
@@ -624,7 +624,7 @@ namespace ams::ncm {
out[count++] = *content_id;
/* Update our last content offset. */
this->last_content_offset = offset + count;
m_last_content_offset = offset + count;
}
}
@@ -639,7 +639,7 @@ namespace ams::ncm {
/* Create the content path. */
PathString content_path;
MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path);
MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path);
/* Open the content file. */
fs::FileHandle file;
@@ -655,9 +655,9 @@ namespace ams::ncm {
}
Result ContentStorageImpl::DisableForcibly() {
this->disabled = true;
m_disabled = true;
this->InvalidateFileCache();
this->placeholder_accessor.InvalidateAll();
m_placeholder_accessor.InvalidateAll();
return ResultSuccess();
}
@@ -668,18 +668,18 @@ namespace ams::ncm {
this->InvalidateFileCache();
/* Ensure the future content directory exists. */
R_TRY(EnsureContentDirectory(new_content_id, this->make_content_path_func, this->root_path));
R_TRY(EnsureContentDirectory(new_content_id, m_make_content_path_func, m_root_path));
/* Ensure the destination placeholder directory exists. */
R_TRY(this->placeholder_accessor.EnsurePlaceHolderDirectory(placeholder_id));
R_TRY(m_placeholder_accessor.EnsurePlaceHolderDirectory(placeholder_id));
/* Obtain the placeholder path. */
PathString placeholder_path;
this->placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id);
m_placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id);
/* Make the old content path. */
PathString content_path;
MakeContentPath(std::addressof(content_path), old_content_id, this->make_content_path_func, this->root_path);
MakeContentPath(std::addressof(content_path), old_content_id, m_make_content_path_func, m_root_path);
/* Move the content to the placeholder path. */
R_TRY_CATCH(fs::RenameFile(content_path, placeholder_path)) {
@@ -692,7 +692,7 @@ namespace ams::ncm {
Result ContentStorageImpl::SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) {
R_TRY(this->EnsureEnabled());
return this->placeholder_accessor.SetPlaceHolderFileSize(placeholder_id, size);
return m_placeholder_accessor.SetPlaceHolderFileSize(placeholder_id, size);
}
Result ContentStorageImpl::ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) {
@@ -702,13 +702,13 @@ namespace ams::ncm {
/* Create the content path. */
PathString content_path;
MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path);
MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path);
/* Open the content file. */
R_TRY(this->OpenContentIdFile(content_id));
/* Read from the requested offset up to the requested size. */
return fs::ReadFile(this->cached_file_handle, offset, buf.GetPointer(), buf.GetSize());
return fs::ReadFile(m_cached_file_handle, offset, buf.GetPointer(), buf.GetSize());
}
Result ContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
@@ -746,7 +746,7 @@ namespace ams::ncm {
R_TRY(this->EnsureEnabled());
/* Attempt to obtain the rights id from the cache. */
if (this->rights_id_cache->Find(out_rights_id.GetPointer(), content_id)) {
if (m_rights_id_cache->Find(out_rights_id.GetPointer(), content_id)) {
return ResultSuccess();
}
@@ -759,7 +759,7 @@ namespace ams::ncm {
R_TRY(GetRightsId(std::addressof(rights_id), path));
/* Store the rights id to the cache. */
this->rights_id_cache->Store(content_id, rights_id);
m_rights_id_cache->Store(content_id, rights_id);
out_rights_id.SetValue(rights_id);
return ResultSuccess();
@@ -778,7 +778,7 @@ namespace ams::ncm {
/* Make the content path. */
PathString path;
MakeContentPath(std::addressof(path), content_id, this->make_content_path_func, this->root_path);
MakeContentPath(std::addressof(path), content_id, m_make_content_path_func, m_root_path);
/* Open the content file. */
fs::FileHandle file;
@@ -790,15 +790,15 @@ namespace ams::ncm {
}
Result ContentStorageImpl::GetFreeSpaceSize(sf::Out<s64> out_size) {
return fs::GetFreeSpaceSize(out_size.GetPointer(), this->root_path);
return fs::GetFreeSpaceSize(out_size.GetPointer(), m_root_path);
}
Result ContentStorageImpl::GetTotalSpaceSize(sf::Out<s64> out_size) {
return fs::GetTotalSpaceSize(out_size.GetPointer(), this->root_path);
return fs::GetTotalSpaceSize(out_size.GetPointer(), m_root_path);
}
Result ContentStorageImpl::FlushPlaceHolder() {
this->placeholder_accessor.InvalidateAll();
m_placeholder_accessor.InvalidateAll();
return ResultSuccess();
}
@@ -808,7 +808,7 @@ namespace ams::ncm {
/* Attempt to get the placeholder file size. */
bool found = false;
s64 file_size = 0;
R_TRY(this->placeholder_accessor.TryGetPlaceHolderFileSize(std::addressof(found), std::addressof(file_size), placeholder_id));
R_TRY(m_placeholder_accessor.TryGetPlaceHolderFileSize(std::addressof(found), std::addressof(file_size), placeholder_id));
/* Set the output if placeholder file is found. */
if (found) {
@@ -818,7 +818,7 @@ namespace ams::ncm {
/* Get the path of the placeholder. */
PathString placeholder_path;
this->placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id);
m_placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id);
/* Open the placeholder file. */
fs::FileHandle file;
@@ -857,19 +857,19 @@ namespace ams::ncm {
{
path_checker = IsContentPath;
PathString path;
MakeBaseContentDirectoryPath(std::addressof(path), this->root_path);
MakeBaseContentDirectoryPath(std::addressof(path), m_root_path);
R_TRY(TraverseDirectory(path, GetHierarchicalContentDirectoryDepth(this->make_content_path_func), fix_file_attributes));
R_TRY(TraverseDirectory(path, GetHierarchicalContentDirectoryDepth(m_make_content_path_func), fix_file_attributes));
}
/* Fix placeholders. */
this->placeholder_accessor.InvalidateAll();
m_placeholder_accessor.InvalidateAll();
{
path_checker = IsPlaceHolderPath;
PathString path;
PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(path), this->root_path);
PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(path), m_root_path);
R_TRY(TraverseDirectory(path, GetHierarchicalContentDirectoryDepth(this->make_content_path_func), fix_file_attributes));
R_TRY(TraverseDirectory(path, GetHierarchicalContentDirectoryDepth(m_make_content_path_func), fix_file_attributes));
}
return ResultSuccess();
@@ -879,13 +879,13 @@ namespace ams::ncm {
R_TRY(this->EnsureEnabled());
/* Attempt to find the rights id in the cache. */
if (this->rights_id_cache->Find(out_rights_id.GetPointer(), cache_content_id)) {
if (m_rights_id_cache->Find(out_rights_id.GetPointer(), cache_content_id)) {
return ResultSuccess();
}
/* Get the placeholder path. */
PathString placeholder_path;
this->placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id);
m_placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id);
/* Substitute mount name with the common mount name. */
Path common_path;
@@ -894,7 +894,7 @@ namespace ams::ncm {
/* Get the rights id. */
ncm::RightsId rights_id;
R_TRY(GetRightsId(std::addressof(rights_id), common_path));
this->rights_id_cache->Store(cache_content_id, rights_id);
m_rights_id_cache->Store(cache_content_id, rights_id);
/* Set output. */
out_rights_id.SetValue(rights_id);

View File

@@ -31,12 +31,12 @@ namespace ams::ncm {
static constexpr size_t MaxDirectoryEntries = 0x10;
public:
fs::DirectoryHandle handles[MaxDirectoryHandles]{};
size_t depth{};
size_t max_depth{};
PathString path{};
fs::DirectoryEntry entries[MaxDirectoryEntries]{};
s64 entry_count{};
fs::DirectoryHandle m_handles[MaxDirectoryHandles]{};
size_t m_depth{};
size_t m_max_depth{};
PathString m_path{};
fs::DirectoryEntry m_entries[MaxDirectoryEntries]{};
s64 m_entry_count{};
public:
constexpr ContentIterator() = default;
~ContentIterator();
@@ -49,18 +49,18 @@ namespace ams::ncm {
Result LoadEntries();
};
protected:
PlaceHolderAccessor placeholder_accessor;
ContentId cached_content_id;
fs::FileHandle cached_file_handle;
RightsIdCache *rights_id_cache;
util::optional<ContentIterator> content_iterator;
util::optional<s32> last_content_offset;
PlaceHolderAccessor m_placeholder_accessor;
ContentId m_cached_content_id;
fs::FileHandle m_cached_file_handle;
RightsIdCache *m_rights_id_cache;
util::optional<ContentIterator> m_content_iterator;
util::optional<s32> m_last_content_offset;
public:
static Result InitializeBase(const char *root_path);
static Result CleanupBase(const char *root_path);
static Result VerifyBase(const char *root_path);
public:
ContentStorageImpl() : placeholder_accessor(), cached_content_id(InvalidContentId), cached_file_handle(), rights_id_cache(nullptr), content_iterator(util::nullopt), last_content_offset(util::nullopt) { /* ... */ }
ContentStorageImpl() : m_placeholder_accessor(), m_cached_content_id(InvalidContentId), m_cached_file_handle(), m_rights_id_cache(nullptr), m_content_iterator(util::nullopt), m_last_content_offset(util::nullopt) { /* ... */ }
~ContentStorageImpl();
Result Initialize(const char *root_path, MakeContentPathFunction content_path_func, MakePlaceHolderPathFunction placeholder_path_func, bool delay_flush, RightsIdCache *rights_id_cache);

View File

@@ -22,15 +22,15 @@ namespace ams::ncm {
NON_COPYABLE(ContentStorageImplBase);
NON_MOVEABLE(ContentStorageImplBase);
protected:
PathString root_path;
MakeContentPathFunction make_content_path_func;
bool disabled;
PathString m_root_path;
MakeContentPathFunction m_make_content_path_func;
bool m_disabled;
protected:
ContentStorageImplBase() : make_content_path_func(), disabled(false) { /* ... */ }
ContentStorageImplBase() : m_make_content_path_func(), m_disabled(false) { /* ... */ }
protected:
/* Helpers. */
Result EnsureEnabled() const {
R_UNLESS(!this->disabled, ncm::ResultInvalidContentStorage());
R_UNLESS(!m_disabled, ncm::ResultInvalidContentStorage());
return ResultSuccess();
}

View File

@@ -20,21 +20,21 @@ namespace ams::ncm::impl {
namespace {
std::atomic<u32> g_mount_name_count;
constinit std::atomic<u32> g_mount_name_count;
}
bool PathView::HasPrefix(util::string_view prefix) const {
return this->path.compare(0, prefix.length(), prefix) == 0;
return m_path.compare(0, prefix.length(), prefix) == 0;
}
bool PathView::HasSuffix(util::string_view suffix) const {
return this->path.compare(this->path.length() - suffix.length(), suffix.length(), suffix) == 0;
return m_path.compare(m_path.length() - suffix.length(), suffix.length(), suffix) == 0;
}
util::string_view PathView::GetFileName() const {
auto pos = this->path.find_last_of("/");
return pos != util::string_view::npos ? this->path.substr(pos + 1) : this->path;
auto pos = m_path.find_last_of("/");
return pos != util::string_view::npos ? m_path.substr(pos + 1) : m_path;
}
MountName CreateUniqueMountName() {

View File

@@ -22,9 +22,9 @@ namespace ams::ncm::impl {
class PathView {
private:
util::string_view path;
util::string_view m_path;
public:
PathView(util::string_view p) : path(p) { /* ...*/ }
PathView(util::string_view p) : m_path(p) { /* ...*/ }
bool HasPrefix(util::string_view prefix) const;
bool HasSuffix(util::string_view suffix) const;
util::string_view GetFileName() const;

View File

@@ -58,7 +58,7 @@ namespace ams::ncm {
/* Attempt to locate the content. */
Path path;
R_TRY_CATCH(this->registered_content->GetPath(std::addressof(path), content_id)) {
R_TRY_CATCH(m_registered_content->GetPath(std::addressof(path), content_id)) {
/* The content is absent, this is fine. */
R_CATCH(ncm::ResultContentNotFound) {
out.SetValue(false);
@@ -72,7 +72,7 @@ namespace ams::ncm {
Result HostContentStorageImpl::GetPath(sf::Out<Path> out, ContentId content_id) {
R_TRY(this->EnsureEnabled());
return this->registered_content->GetPath(out.GetPointer(), content_id);
return m_registered_content->GetPath(out.GetPointer(), content_id);
}
Result HostContentStorageImpl::GetPlaceHolderPath(sf::Out<Path> out, PlaceHolderId placeholder_id) {
@@ -105,7 +105,7 @@ namespace ams::ncm {
}
Result HostContentStorageImpl::DisableForcibly() {
this->disabled = true;
m_disabled = true;
return ResultSuccess();
}
@@ -149,7 +149,7 @@ namespace ams::ncm {
/* Get the content path. */
Path path;
R_TRY(this->registered_content->GetPath(std::addressof(path), content_id));
R_TRY(m_registered_content->GetPath(std::addressof(path), content_id));
/* Acquire the rights id for the content. */
RightsId rights_id;
@@ -201,12 +201,12 @@ namespace ams::ncm {
Result HostContentStorageImpl::RegisterPath(const ContentId &content_id, const Path &path) {
AMS_ABORT_UNLESS(spl::IsDevelopment());
return this->registered_content->RegisterPath(content_id, path);
return m_registered_content->RegisterPath(content_id, path);
}
Result HostContentStorageImpl::ClearRegisteredPath() {
AMS_ABORT_UNLESS(spl::IsDevelopment());
this->registered_content->ClearPaths();
m_registered_content->ClearPaths();
return ResultSuccess();
}

View File

@@ -20,12 +20,12 @@ namespace ams::ncm {
class HostContentStorageImpl {
protected:
RegisteredHostContent *registered_content;
bool disabled;
RegisteredHostContent *m_registered_content;
bool m_disabled;
protected:
/* Helpers. */
Result EnsureEnabled() const {
R_UNLESS(!this->disabled, ncm::ResultInvalidContentStorage());
R_UNLESS(!m_disabled, ncm::ResultInvalidContentStorage());
return ResultSuccess();
}
@@ -39,7 +39,7 @@ namespace ams::ncm {
return ResultSuccess();
}
public:
HostContentStorageImpl(RegisteredHostContent *registered_content) : registered_content(registered_content), disabled(false) { /* ... */ }
HostContentStorageImpl(RegisteredHostContent *registered_content) : m_registered_content(registered_content), m_disabled(false) { /* ... */ }
public:
/* Actual commands. */
virtual Result GeneratePlaceHolderId(sf::Out<PlaceHolderId> out);

View File

@@ -52,28 +52,28 @@ namespace ams::ncm {
}
void InstallTaskBase::Cancel() {
std::scoped_lock lk(this->cancel_mutex);
this->cancel_requested = true;
std::scoped_lock lk(m_cancel_mutex);
m_cancel_requested = true;
}
void InstallTaskBase::ResetCancel() {
std::scoped_lock lk(this->cancel_mutex);
this->cancel_requested = false;
std::scoped_lock lk(m_cancel_mutex);
m_cancel_requested = false;
}
bool InstallTaskBase::IsCancelRequested() {
std::scoped_lock lk(this->cancel_mutex);
return this->cancel_requested;
std::scoped_lock lk(m_cancel_mutex);
return m_cancel_requested;
}
Result InstallTaskBase::Initialize(StorageId install_storage, InstallTaskDataBase *data, u32 config) {
R_UNLESS(IsInstallableStorage(install_storage), ncm::ResultUnknownStorage());
this->install_storage = install_storage;
this->data = data;
this->config = config;
m_install_storage = install_storage;
m_data = data;
m_config = config;
return data->GetProgress(std::addressof(this->progress));
return data->GetProgress(std::addressof(m_progress));
}
Result InstallTaskBase::Prepare() {
@@ -129,14 +129,14 @@ namespace ams::ncm {
Result InstallTaskBase::CalculateRequiredSize(s64 *out_size) {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
s64 required_size = 0;
/* Iterate over each entry. */
for (s32 i = 0; i < count; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
const auto reader = content_meta.GetReader();
/* Sum the sizes from the content infos. */
@@ -178,13 +178,13 @@ namespace ams::ncm {
Result InstallTaskBase::Cleanup() {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
/* Iterate over content meta. */
for (s32 i = 0; i < count; i++) {
/* Get the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Cleanup the content meta. */
/* N doesn't check the result of this. */
@@ -192,7 +192,7 @@ namespace ams::ncm {
}
/* Cleanup the data and progress. */
R_TRY(this->data->Cleanup());
R_TRY(m_data->Cleanup());
this->CleanupProgress();
return ResultSuccess();
@@ -224,7 +224,7 @@ namespace ams::ncm {
Result InstallTaskBase::ListContentMetaKey(s32 *out_keys_written, StorageContentMetaKey *out_keys, s32 out_keys_count, s32 offset, ListContentMetaKeyFilter filter) {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
/* Offset exceeds keys that can be written. */
if (count <= offset) {
@@ -239,7 +239,7 @@ namespace ams::ncm {
for (s32 i = offset; i < num_keys; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Write output StorageContentMetaKey. */
const auto reader = content_meta.GetReader();
@@ -256,7 +256,7 @@ namespace ams::ncm {
for (s32 i = 0; i < count; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Create a reader and check if the content has been committed. */
const auto reader = content_meta.GetReader();
@@ -289,7 +289,7 @@ namespace ams::ncm {
Result InstallTaskBase::ListApplicationContentMetaKey(s32 *out_keys_written, ApplicationContentMetaKey *out_keys, s32 out_keys_count, s32 offset) {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
/* Offset exceeds keys that can be written. */
if (count <= offset) {
@@ -303,7 +303,7 @@ namespace ams::ncm {
for (s32 i = offset; i < max; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Create a reader. */
const auto reader = content_meta.GetReader();
@@ -332,16 +332,16 @@ namespace ams::ncm {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
/* Iterate over content meta. */
for (s32 i = 0; i < count; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Update the data (and check result) when we are done. */
const auto DoUpdate = [&]() ALWAYS_INLINE_LAMBDA { return this->data->Update(content_meta, i); };
const auto DoUpdate = [&]() ALWAYS_INLINE_LAMBDA { return m_data->Update(content_meta, i); };
{
auto update_guard = SCOPE_GUARD { DoUpdate(); };
@@ -385,7 +385,7 @@ namespace ams::ncm {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
s32 num_not_committed = 0;
@@ -393,7 +393,7 @@ namespace ams::ncm {
for (s32 i = 0; i < count; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Create a reader. */
const auto reader = content_meta.GetReader();
@@ -419,7 +419,7 @@ namespace ams::ncm {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
/* List of storages to commit. */
StorageList commit_list;
@@ -428,7 +428,7 @@ namespace ams::ncm {
for (s32 i = 0; i < count; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Create a reader. */
const auto reader = content_meta.GetReader();
@@ -447,7 +447,7 @@ namespace ams::ncm {
}
/* Helper for performing an update. */
const auto DoUpdate = [&]() ALWAYS_INLINE_LAMBDA { return this->data->Update(content_meta, i); };
const auto DoUpdate = [&]() ALWAYS_INLINE_LAMBDA { return m_data->Update(content_meta, i); };
/* Commit the current meta. */
{
@@ -522,13 +522,13 @@ namespace ams::ncm {
Result InstallTaskBase::IncludesExFatDriver(bool *out) {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
/* Iterate over content meta. */
for (s32 i = 0; i < count; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Check if the attributes are set for including the exfat driver. */
if (content_meta.GetReader().GetHeader()->attributes & ContentMetaAttribute_IncludesExFatDriver) {
@@ -559,26 +559,26 @@ namespace ams::ncm {
}
/* Update the hash for the new data. */
this->sha256_generator.Update(data, data_size);
m_sha256_generator.Update(data, data_size);
return ResultSuccess();
}
Result InstallTaskBase::WritePlaceHolder(const ContentMetaKey &key, InstallContentInfo *content_info) {
if (content_info->is_sha256_calculated) {
/* Update the hash with the buffered data. */
this->sha256_generator.InitializeWithContext(std::addressof(content_info->context));
this->sha256_generator.Update(content_info->buffered_data, content_info->buffered_data_size);
m_sha256_generator.InitializeWithContext(std::addressof(content_info->context));
m_sha256_generator.Update(content_info->buffered_data, content_info->buffered_data_size);
} else {
/* Initialize the generator. */
this->sha256_generator.Initialize();
m_sha256_generator.Initialize();
}
{
ON_SCOPE_EXIT {
/* Update this content info's sha256 data. */
this->sha256_generator.GetContext(std::addressof(content_info->context));
content_info->buffered_data_size = this->sha256_generator.GetBufferedDataSize();
this->sha256_generator.GetBufferedData(content_info->buffered_data, this->sha256_generator.GetBufferedDataSize());
m_sha256_generator.GetContext(std::addressof(content_info->context));
content_info->buffered_data_size = m_sha256_generator.GetBufferedDataSize();
m_sha256_generator.GetBufferedData(content_info->buffered_data, m_sha256_generator.GetBufferedDataSize());
content_info->is_sha256_calculated = true;
};
@@ -589,11 +589,11 @@ namespace ams::ncm {
/* Compare generated hash to expected hash if verification required. */
if (content_info->verify_digest) {
u8 hash[crypto::Sha256Generator::HashSize];
this->sha256_generator.GetHash(hash, crypto::Sha256Generator::HashSize);
m_sha256_generator.GetHash(hash, crypto::Sha256Generator::HashSize);
R_UNLESS(std::memcmp(hash, content_info->digest.data, crypto::Sha256Generator::HashSize) == 0, ncm::ResultInvalidContentHash());
}
if (hos::GetVersion() >= hos::Version_2_0_0 && !(this->config & InstallConfig_IgnoreTicket)) {
if (hos::GetVersion() >= hos::Version_2_0_0 && !(m_config & InstallConfig_IgnoreTicket)) {
ncm::RightsId rights_id;
{
/* Open the content storage and obtain the rights id. */
@@ -630,7 +630,7 @@ namespace ams::ncm {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
for (s32 i = 0; i < count; i++) {
R_UNLESS(!this->IsCancelRequested(), ncm::ResultCreatePlaceHolderCancelled());
@@ -639,10 +639,10 @@ namespace ams::ncm {
std::scoped_lock lk(s_placeholder_mutex);
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Update the data (and check result) when we are done. */
const auto DoUpdate = [&]() ALWAYS_INLINE_LAMBDA { return this->data->Update(content_meta, i); };
const auto DoUpdate = [&]() ALWAYS_INLINE_LAMBDA { return m_data->Update(content_meta, i); };
{
auto update_guard = SCOPE_GUARD { DoUpdate(); };
@@ -768,7 +768,7 @@ namespace ams::ncm {
R_TRY(this->GetInstallContentMetaDataFromPath(std::addressof(meta), path, content_info, source_version));
/* Update the storage id if BuiltInSystem. */
if (this->install_storage == StorageId::BuiltInSystem) {
if (m_install_storage == StorageId::BuiltInSystem) {
InstallContentMetaWriter writer(meta.Get(), meta.GetSize());
writer.SetStorageId(StorageId::BuiltInSystem);
}
@@ -780,7 +780,7 @@ namespace ams::ncm {
}
/* Push the data. */
R_TRY(this->data->Push(meta.Get(), meta.GetSize()));
R_TRY(m_data->Push(meta.Get(), meta.GetSize()));
/* Don't delete the placeholder if not temporary. */
if (!is_temporary) {
@@ -801,7 +801,7 @@ namespace ams::ncm {
reader.ConvertToInstallContentMeta(tmp_buffer.Get(), tmp_buffer.GetSize(), InstallContentInfo::Make(ContentInfo::Make(content_id, size, ContentType::Meta), meta_type));
/* Push the content meta. */
this->data->Push(tmp_buffer.Get(), tmp_buffer.GetSize());
m_data->Push(tmp_buffer.Get(), tmp_buffer.GetSize());
return ResultSuccess();
}
@@ -825,7 +825,7 @@ namespace ams::ncm {
for (s32 i = 0; i < count; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Create a reader. */
const InstallContentMetaReader reader = content_meta.GetReader();
@@ -846,7 +846,7 @@ namespace ams::ncm {
const ContentMetaKey content_meta_info_key = content_meta_info.ToKey();
/* If exfat driver is not included or is required, prepare the content meta. */
if (!(content_meta_info.attributes & ContentMetaAttribute_IncludesExFatDriver) || (this->config & InstallConfig_RequiresExFatDriver)) {
if (!(content_meta_info.attributes & ContentMetaAttribute_IncludesExFatDriver) || (m_config & InstallConfig_RequiresExFatDriver)) {
R_TRY(this->PrepareContentMetaIfLatest(content_meta_info_key));
}
}
@@ -863,7 +863,7 @@ namespace ams::ncm {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
/* Iterate over content meta. */
for (s32 i = 0; i < count; i++) {
@@ -899,7 +899,7 @@ namespace ams::ncm {
} R_END_TRY_CATCH;
/* Exfat driver included, but not required. */
if (content_meta_info.attributes & ContentMetaAttribute_IncludesExFatDriver && !(this->config & InstallConfig_RequiresExFatDriver)) {
if (content_meta_info.attributes & ContentMetaAttribute_IncludesExFatDriver && !(m_config & InstallConfig_RequiresExFatDriver)) {
continue;
}
@@ -937,7 +937,7 @@ namespace ams::ncm {
Result InstallTaskBase::IsNewerThanInstalled(bool *out, const ContentMetaKey &key) {
/* Obtain a list of suitable storage ids. */
auto storage_list = GetStorageList(this->install_storage);
auto storage_list = GetStorageList(m_install_storage);
/* Iterate over storage ids. */
for (s32 i = 0; i < storage_list.Count(); i++) {
@@ -969,11 +969,11 @@ namespace ams::ncm {
}
Result InstallTaskBase::CountInstallContentMetaData(s32 *out_count) {
return this->data->Count(out_count);
return m_data->Count(out_count);
}
Result InstallTaskBase::GetInstallContentMetaData(InstallContentMeta *out_content_meta, s32 index) {
return this->data->Get(out_content_meta, index);
return m_data->Get(out_content_meta, index);
}
Result InstallTaskBase::DeleteInstallContentMetaData(const ContentMetaKey *keys, s32 num_keys) {
@@ -994,7 +994,7 @@ namespace ams::ncm {
}
/* Delete the data if count < 1. */
return this->data->Delete(keys, num_keys);
return m_data->Delete(keys, num_keys);
}
Result InstallTaskBase::GetInstallContentMetaDataFromPath(AutoBuffer *out, const Path &path, const InstallContentInfo &content_info, util::optional<u32> source_version) {
@@ -1036,13 +1036,13 @@ namespace ams::ncm {
.install_state = InstallState::Prepared,
.verify_digest = info.verify_digest,
.storage_id = StorageId::BuiltInSystem,
.is_temporary = is_tmp ? *is_tmp : (this->install_storage != StorageId::BuiltInSystem),
.is_temporary = is_tmp ? *is_tmp : (m_install_storage != StorageId::BuiltInSystem),
};
}
InstallProgress InstallTaskBase::GetProgress() {
std::scoped_lock lk(this->progress_mutex);
return this->progress;
std::scoped_lock lk(m_progress_mutex);
return m_progress;
}
void InstallTaskBase::ResetLastResult() {
@@ -1050,57 +1050,57 @@ namespace ams::ncm {
}
void InstallTaskBase::SetTotalSize(s64 size) {
std::scoped_lock(this->progress_mutex);
this->progress.total_size = size;
std::scoped_lock lk(m_progress_mutex);
m_progress.total_size = size;
}
void InstallTaskBase::IncrementProgress(s64 size) {
std::scoped_lock lk(this->progress_mutex);
this->progress.installed_size += size;
std::scoped_lock lk(m_progress_mutex);
m_progress.installed_size += size;
}
void InstallTaskBase::SetLastResult(Result last_result) {
std::scoped_lock lk(this->progress_mutex);
this->data->SetLastResult(last_result);
this->progress.SetLastResult(last_result);
std::scoped_lock lk(m_progress_mutex);
m_data->SetLastResult(last_result);
m_progress.SetLastResult(last_result);
}
void InstallTaskBase::CleanupProgress() {
std::scoped_lock(this->progress_mutex);
this->progress = {};
std::scoped_lock lk(m_progress_mutex);
m_progress = {};
}
InstallThroughput InstallTaskBase::GetThroughput() {
std::scoped_lock lk(this->throughput_mutex);
return this->throughput;
std::scoped_lock lk(m_throughput_mutex);
return m_throughput;
}
void InstallTaskBase::ResetThroughputMeasurement() {
std::scoped_lock lk(this->throughput_mutex);
this->throughput = { .elapsed_time = TimeSpan() };
this->throughput_start_time = TimeSpan();
std::scoped_lock lk(m_throughput_mutex);
m_throughput = { .elapsed_time = TimeSpan() };
m_throughput_start_time = TimeSpan();
}
void InstallTaskBase::StartThroughputMeasurement() {
std::scoped_lock lk(this->throughput_mutex);
this->throughput = { .elapsed_time = TimeSpan() };
this->throughput_start_time = os::GetSystemTick().ToTimeSpan();
std::scoped_lock lk(m_throughput_mutex);
m_throughput = { .elapsed_time = TimeSpan() };
m_throughput_start_time = os::GetSystemTick().ToTimeSpan();
}
void InstallTaskBase::UpdateThroughputMeasurement(s64 throughput) {
std::scoped_lock lk(this->throughput_mutex);
std::scoped_lock lk(m_throughput_mutex);
/* Update throughput only if start time has been set. */
if (this->throughput_start_time.GetNanoSeconds() != 0) {
this->throughput.installed += throughput;
this->throughput.elapsed_time = os::GetSystemTick().ToTimeSpan() - this->throughput_start_time;
if (m_throughput_start_time.GetNanoSeconds() != 0) {
m_throughput.installed += throughput;
m_throughput.elapsed_time = os::GetSystemTick().ToTimeSpan() - m_throughput_start_time;
}
}
Result InstallTaskBase::CalculateContentsSize(s64 *out_size, const ContentMetaKey &key, StorageId storage_id) {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
/* Open the content storage. */
ContentStorage content_storage;
@@ -1110,7 +1110,7 @@ namespace ams::ncm {
for (s32 i = 0; i < count; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Create a reader. */
const InstallContentMetaReader reader = content_meta.GetReader();
@@ -1175,7 +1175,7 @@ namespace ams::ncm {
content_storage.GetPlaceHolderPath(std::addressof(path), placeholder_id);
/* Read the variation list. */
R_TRY(ReadVariationContentMetaInfoList(out_count, out_meta_infos, path, this->firmware_variation_id));
R_TRY(ReadVariationContentMetaInfoList(out_count, out_meta_infos, path, m_firmware_variation_id));
/* Delete the placeholder. */
content_storage.DeletePlaceHolder(placeholder_id);
@@ -1185,7 +1185,7 @@ namespace ams::ncm {
Result InstallTaskBase::FindMaxRequiredApplicationVersion(u32 *out) {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
u32 max_version = 0;
@@ -1193,7 +1193,7 @@ namespace ams::ncm {
for (s32 i = 0; i < count; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Create a reader. */
const InstallContentMetaReader reader = content_meta.GetReader();
@@ -1216,14 +1216,14 @@ namespace ams::ncm {
/* Count the number of content meta entries. */
s32 data_count;
R_TRY(this->data->Count(std::addressof(data_count)));
R_TRY(m_data->Count(std::addressof(data_count)));
/* Iterate over content meta. */
s32 count = 0;
for (s32 i = offset; i < data_count && count < out_list_size; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Create a reader. */
const InstallContentMetaReader reader = content_meta.GetReader();
@@ -1269,15 +1269,15 @@ namespace ams::ncm {
}
void InstallTaskBase::SetProgressState(InstallProgressState state) {
std::scoped_lock(this->progress_mutex);
this->data->SetState(state);
this->progress.state = state;
std::scoped_lock lk(m_progress_mutex);
m_data->SetState(state);
m_progress.state = state;
}
Result InstallTaskBase::FindMaxRequiredSystemVersion(u32 *out) {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
u32 max_version = 0;
@@ -1285,7 +1285,7 @@ namespace ams::ncm {
for (s32 i = 0; i < count; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Create a reader. */
const InstallContentMetaReader reader = content_meta.GetReader();
@@ -1330,7 +1330,7 @@ namespace ams::ncm {
Result InstallTaskBase::ListRightsIds(s32 *out_count, Span<RightsId> out_span, const ContentMetaKey &key, s32 offset) {
/* Count the number of content meta entries. */
s32 count;
R_TRY(this->data->Count(std::addressof(count)));
R_TRY(m_data->Count(std::addressof(count)));
/* Ensure count is >= 1. */
R_UNLESS(count >= 1, ncm::ResultContentMetaNotFound());
@@ -1339,7 +1339,7 @@ namespace ams::ncm {
for (s32 i = 0; i < count; i++) {
/* Obtain the content meta. */
InstallContentMeta content_meta;
R_TRY(this->data->Get(std::addressof(content_meta), i));
R_TRY(m_data->Get(std::addressof(content_meta), i));
/* Create a reader. */
const InstallContentMetaReader reader = content_meta.GetReader();

View File

@@ -76,13 +76,13 @@ namespace ams::ncm {
Result MemoryInstallTaskData::GetProgress(InstallProgress *out_progress) {
/* Initialize install progress. */
InstallProgress install_progress = {
.state = this->state,
.state = m_state,
};
install_progress.SetLastResult(this->last_result);
install_progress.SetLastResult(m_last_result);
/* Only states after prepared are allowed. */
if (this->state != InstallProgressState::NotPrepared && this->state != InstallProgressState::DataPrepared) {
for (auto &data_holder : this->data_list) {
if (m_state != InstallProgressState::NotPrepared && m_state != InstallProgressState::DataPrepared) {
for (auto &data_holder : m_data_list) {
const InstallContentMetaReader reader = data_holder.GetReader();
/* Sum the sizes from this entry's content infos. */
@@ -99,22 +99,22 @@ namespace ams::ncm {
}
Result MemoryInstallTaskData::GetSystemUpdateTaskApplyInfo(SystemUpdateTaskApplyInfo *out_info) {
*out_info = this->system_update_task_apply_info;
*out_info = m_system_update_task_apply_info;
return ResultSuccess();
}
Result MemoryInstallTaskData::SetState(InstallProgressState state) {
this->state = state;
m_state = state;
return ResultSuccess();
}
Result MemoryInstallTaskData::SetLastResult(Result result) {
this->last_result = result;
m_last_result = result;
return ResultSuccess();
}
Result MemoryInstallTaskData::SetSystemUpdateTaskApplyInfo(SystemUpdateTaskApplyInfo info) {
this->system_update_task_apply_info = info;
m_system_update_task_apply_info = info;
return ResultSuccess();
}
@@ -132,7 +132,7 @@ namespace ams::ncm {
std::memcpy(holder->data.get(), data, size);
/* Put the data holder into the data list. */
this->data_list.push_back(*holder);
m_data_list.push_back(*holder);
/* Relinquish control over the memory allocated to the data holder. */
holder.release();
@@ -141,14 +141,14 @@ namespace ams::ncm {
}
Result MemoryInstallTaskData::Count(s32 *out) {
*out = this->data_list.size();
*out = m_data_list.size();
return ResultSuccess();
}
Result MemoryInstallTaskData::GetSize(size_t *out_size, s32 index) {
/* Find the correct entry in the list. */
s32 count = 0;
for (auto &data_holder : this->data_list) {
for (auto &data_holder : m_data_list) {
if (index == count++) {
*out_size = data_holder.size;
return ResultSuccess();
@@ -161,7 +161,7 @@ namespace ams::ncm {
Result MemoryInstallTaskData::Get(s32 index, void *out, size_t out_size) {
/* Find the correct entry in the list. */
s32 count = 0;
for (auto &data_holder : this->data_list) {
for (auto &data_holder : m_data_list) {
if (index == count++) {
R_UNLESS(out_size >= data_holder.size, ncm::ResultBufferInsufficient());
std::memcpy(out, data_holder.data.get(), data_holder.size);
@@ -175,7 +175,7 @@ namespace ams::ncm {
Result MemoryInstallTaskData::Update(s32 index, const void *data, size_t data_size) {
/* Find the correct entry in the list. */
s32 count = 0;
for (auto &data_holder : this->data_list) {
for (auto &data_holder : m_data_list) {
if (index == count++) {
R_UNLESS(data_size == data_holder.size, ncm::ResultBufferInsufficient());
std::memcpy(data_holder.data.get(), data, data_size);
@@ -191,9 +191,9 @@ namespace ams::ncm {
const auto &key = keys[i];
/* Find and remove matching data from the list. */
for (auto &data_holder : this->data_list) {
for (auto &data_holder : m_data_list) {
if (key == data_holder.GetReader().GetKey()) {
this->data_list.erase(this->data_list.iterator_to(data_holder));
m_data_list.erase(m_data_list.iterator_to(data_holder));
delete std::addressof(data_holder);
break;
}
@@ -204,9 +204,9 @@ namespace ams::ncm {
}
Result MemoryInstallTaskData::Cleanup() {
while (!this->data_list.empty()) {
auto *data_holder = std::addressof(this->data_list.front());
this->data_list.pop_front();
while (!m_data_list.empty()) {
auto *data_holder = std::addressof(m_data_list.front());
m_data_list.pop_front();
delete data_holder;
}
return ResultSuccess();
@@ -227,21 +227,21 @@ namespace ams::ncm {
}
Result FileInstallTaskData::Initialize(const char *path) {
std::strncpy(this->path, path, sizeof(this->path));
this->path[sizeof(this->path) - 1] = '\x00';
return this->Read(std::addressof(this->header), sizeof(Header), 0);
std::strncpy(m_path, path, sizeof(m_path));
m_path[sizeof(m_path) - 1] = '\x00';
return this->Read(std::addressof(m_header), sizeof(Header), 0);
}
Result FileInstallTaskData::GetProgress(InstallProgress *out_progress) {
/* Initialize install progress. */
InstallProgress install_progress = {
.state = this->header.progress_state,
.state = m_header.progress_state,
};
install_progress.SetLastResult(this->header.last_result);
install_progress.SetLastResult(m_header.last_result);
/* Only states after prepared are allowed. */
if (this->header.progress_state != InstallProgressState::NotPrepared && this->header.progress_state != InstallProgressState::DataPrepared) {
for (size_t i = 0; i < this->header.count; i++) {
if (m_header.progress_state != InstallProgressState::NotPrepared && m_header.progress_state != InstallProgressState::DataPrepared) {
for (size_t i = 0; i < m_header.count; i++) {
/* Obtain the content meta for this entry. */
InstallContentMeta content_meta;
R_TRY(InstallTaskDataBase::Get(std::addressof(content_meta), i));
@@ -261,47 +261,47 @@ namespace ams::ncm {
}
Result FileInstallTaskData::GetSystemUpdateTaskApplyInfo(SystemUpdateTaskApplyInfo *out_info) {
*out_info = this->header.system_update_task_apply_info;
*out_info = m_header.system_update_task_apply_info;
return ResultSuccess();
}
Result FileInstallTaskData::SetState(InstallProgressState state) {
this->header.progress_state = state;
m_header.progress_state = state;
return this->WriteHeader();
}
Result FileInstallTaskData::SetLastResult(Result result) {
this->header.last_result = result;
m_header.last_result = result;
return this->WriteHeader();
}
Result FileInstallTaskData::SetSystemUpdateTaskApplyInfo(SystemUpdateTaskApplyInfo info) {
this->header.system_update_task_apply_info = info;
m_header.system_update_task_apply_info = info;
return this->WriteHeader();
}
Result FileInstallTaskData::Push(const void *data, size_t data_size) {
R_UNLESS(this->header.count < this->header.max_entries, ncm::ResultBufferInsufficient());
R_UNLESS(m_header.count < m_header.max_entries, ncm::ResultBufferInsufficient());
/* Create a new entry info. Data of the given size will be stored at the end of the file. */
const EntryInfo entry_info = { this->header.last_data_offset, static_cast<s64>(data_size) };
const EntryInfo entry_info = { m_header.last_data_offset, static_cast<s64>(data_size) };
/* Write the new entry info. */
R_TRY(this->Write(std::addressof(entry_info), sizeof(EntryInfo), GetEntryInfoOffset(this->header.count)));
R_TRY(this->Write(std::addressof(entry_info), sizeof(EntryInfo), GetEntryInfoOffset(m_header.count)));
/* Write the data to the offset in the entry info. */
R_TRY(this->Write(data, data_size, entry_info.offset));
/* Update the header for the new entry. */
this->header.last_data_offset += data_size;
this->header.count++;
m_header.last_data_offset += data_size;
m_header.count++;
/* Write the updated header. */
return this->WriteHeader();
}
Result FileInstallTaskData::Count(s32 *out) {
*out = this->header.count;
*out = m_header.count;
return ResultSuccess();
}
@@ -334,12 +334,12 @@ namespace ams::ncm {
Result FileInstallTaskData::Delete(const ContentMetaKey *keys, s32 num_keys) {
/* Create the path for the temporary data. */
BoundedPath tmp_path(this->path);
BoundedPath tmp_path(m_path);
tmp_path.Append(".tmp");
/* Create a new temporary install task data. */
FileInstallTaskData install_task_data;
R_TRY(FileInstallTaskData::Create(tmp_path, this->header.max_entries));
R_TRY(FileInstallTaskData::Create(tmp_path, m_header.max_entries));
R_TRY(install_task_data.Initialize(tmp_path));
/* Get the number of entries. */
@@ -361,37 +361,37 @@ namespace ams::ncm {
}
/* Change from our current data to the new data. */
this->header = install_task_data.header;
R_TRY(fs::DeleteFile(this->path));
return fs::RenameFile(tmp_path, this->path);
m_header = install_task_data.m_header;
R_TRY(fs::DeleteFile(m_path));
return fs::RenameFile(tmp_path, m_path);
}
Result FileInstallTaskData::Cleanup() {
this->header = MakeInitialHeader(this->header.max_entries);
m_header = MakeInitialHeader(m_header.max_entries);
return this->WriteHeader();
}
Result FileInstallTaskData::GetEntryInfo(EntryInfo *out_entry_info, s32 index) {
AMS_ABORT_UNLESS(static_cast<u32>(index) < this->header.count);
AMS_ABORT_UNLESS(static_cast<u32>(index) < m_header.count);
return this->Read(out_entry_info, sizeof(EntryInfo), GetEntryInfoOffset(index));
}
Result FileInstallTaskData::Write(const void *data, size_t size, s64 offset) {
fs::FileHandle file;
R_TRY(fs::OpenFile(std::addressof(file), this->path, fs::OpenMode_Write | fs::OpenMode_AllowAppend));
R_TRY(fs::OpenFile(std::addressof(file), m_path, fs::OpenMode_Write | fs::OpenMode_AllowAppend));
ON_SCOPE_EXIT { fs::CloseFile(file); };
return fs::WriteFile(file, offset, data, size, fs::WriteOption::Flush);
}
Result FileInstallTaskData::Read(void *out, size_t out_size, s64 offset) {
fs::FileHandle file;
R_TRY(fs::OpenFile(std::addressof(file), this->path, fs::OpenMode_Read));
R_TRY(fs::OpenFile(std::addressof(file), m_path, fs::OpenMode_Read));
ON_SCOPE_EXIT { fs::CloseFile(file); };
return fs::ReadFile(file, offset, out, out_size);
}
Result FileInstallTaskData::WriteHeader() {
return this->Write(std::addressof(this->header), sizeof(Header), 0);
return this->Write(std::addressof(m_header), sizeof(Header), 0);
}
}

View File

@@ -18,29 +18,29 @@
namespace ams::ncm {
void HeapState::Initialize(lmem::HeapHandle heap_handle) {
std::scoped_lock lk(this->mutex);
this->heap_handle = heap_handle;
std::scoped_lock lk(m_mutex);
m_heap_handle = heap_handle;
}
void HeapState::Allocate(size_t size) {
std::scoped_lock lk(this->mutex);
this->total_alloc_size += size;
this->peak_total_alloc_size = std::max(this->total_alloc_size, this->peak_total_alloc_size);
this->peak_alloc_size = std::max(size, this->peak_alloc_size);
std::scoped_lock lk(m_mutex);
m_total_alloc_size += size;
m_peak_total_alloc_size = std::max(m_total_alloc_size, m_peak_total_alloc_size);
m_peak_alloc_size = std::max(size, m_peak_alloc_size);
}
void HeapState::Free(size_t size) {
std::scoped_lock lk(this->mutex);
this->total_alloc_size -= size;
std::scoped_lock lk(m_mutex);
m_total_alloc_size -= size;
}
void HeapState::GetMemoryResourceState(MemoryResourceState *out) {
*out = {};
std::scoped_lock lk(this->mutex);
out->peak_total_alloc_size = this->peak_total_alloc_size;
out->peak_alloc_size = this->peak_alloc_size;
out->total_free_size = lmem::GetExpHeapTotalFreeSize(this->heap_handle);
out->allocatable_size = lmem::GetExpHeapAllocatableSize(this->heap_handle, alignof(s32));
std::scoped_lock lk(m_mutex);
out->peak_total_alloc_size = m_peak_total_alloc_size;
out->peak_alloc_size = m_peak_alloc_size;
out->total_free_size = lmem::GetExpHeapTotalFreeSize(m_heap_handle);
out->allocatable_size = lmem::GetExpHeapAllocatableSize(m_heap_handle, alignof(s32));
}
HeapState &GetHeapState() {

View File

@@ -28,7 +28,7 @@ namespace ams::ncm {
size_t entries_written = 0;
/* Iterate over all entries. */
for (auto entry = this->kvs->begin(); entry != this->kvs->end(); entry++) {
for (auto entry = m_kvs->begin(); entry != m_kvs->end(); entry++) {
const ContentMetaKey key = entry->GetKey();
/* Check if this entry matches the given filters. */
@@ -70,7 +70,7 @@ namespace ams::ncm {
util::optional<ContentMetaKey> found_key = util::nullopt;
/* Find the last key with the desired program id. */
for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) {
for (auto entry = m_kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != m_kvs->end(); entry++) {
/* No further entries will match the program id, discontinue. */
if (entry->GetKey().id != id) {
break;

View File

@@ -23,7 +23,7 @@ namespace ams::ncm {
}
Result PackageInstallTask::Initialize(const char *package_root, StorageId storage_id, void *buffer, size_t buffer_size, bool ignore_ticket) {
return PackageInstallTaskBase::Initialize(package_root, buffer, buffer_size, storage_id, std::addressof(this->data), ignore_ticket ? InstallConfig_IgnoreTicket : InstallConfig_None);
return PackageInstallTaskBase::Initialize(package_root, buffer, buffer_size, storage_id, std::addressof(m_data), ignore_ticket ? InstallConfig_IgnoreTicket : InstallConfig_None);
}
Result PackageInstallTask::GetInstallContentMetaInfo(InstallContentMetaInfo *out_info, const ContentMetaKey &key) {

View File

@@ -19,9 +19,9 @@ namespace ams::ncm {
Result PackageInstallTaskBase::Initialize(const char *package_root_path, void *buffer, size_t buffer_size, StorageId storage_id, InstallTaskDataBase *data, u32 config) {
R_TRY(InstallTaskBase::Initialize(storage_id, data, config));
this->package_root.Set(package_root_path);
this->buffer = buffer;
this->buffer_size = buffer_size;
m_package_root.Set(package_root_path);
m_buffer = buffer;
m_buffer_size = buffer_size;
return ResultSuccess();
}
@@ -45,7 +45,7 @@ namespace ams::ncm {
while (true) {
/* Read as much of the remainder of the file as possible. */
size_t size_read;
R_TRY(fs::ReadFile(std::addressof(size_read), file, content_info->written, this->buffer, this->buffer_size));
R_TRY(fs::ReadFile(std::addressof(size_read), file, content_info->written, m_buffer, m_buffer_size));
/* There is nothing left to read. */
if (size_read == 0) {
@@ -53,7 +53,7 @@ namespace ams::ncm {
}
/* Write the placeholder. */
R_TRY(this->WritePlaceHolderBuffer(content_info, this->buffer, size_read));
R_TRY(this->WritePlaceHolderBuffer(content_info, m_buffer, size_read));
}
return ResultSuccess();
@@ -110,25 +110,25 @@ namespace ams::ncm {
void PackageInstallTaskBase::CreateContentPath(PackagePath *out_path, ContentId content_id) {
char str[ContentIdStringLength + 1] = {};
GetStringFromContentId(str, sizeof(str), content_id);
out_path->SetFormat("%s%s%s", this->package_root.Get(), str, ".nca");
out_path->SetFormat("%s%s%s", m_package_root.Get(), str, ".nca");
}
void PackageInstallTaskBase::CreateContentMetaPath(PackagePath *out_path, ContentId content_id) {
char str[ContentIdStringLength + 1] = {};
GetStringFromContentId(str, sizeof(str), content_id);
out_path->SetFormat("%s%s%s", this->package_root.Get(), str, ".cnmt.nca");
out_path->SetFormat("%s%s%s", m_package_root.Get(), str, ".cnmt.nca");
}
void PackageInstallTaskBase::CreateTicketPath(PackagePath *out_path, fs::RightsId id) {
char str[RightsIdStringLength + 1] = {};
GetStringFromRightsId(str, sizeof(str), id);
out_path->SetFormat("%s%s%s", this->package_root.Get(), str, ".tik");
out_path->SetFormat("%s%s%s", m_package_root.Get(), str, ".tik");
}
void PackageInstallTaskBase::CreateCertificatePath(PackagePath *out_path, fs::RightsId id) {
char str[RightsIdStringLength + 1] = {};
GetStringFromRightsId(str, sizeof(str), id);
out_path->SetFormat("%s%s%s", this->package_root.Get(), str, ".cert");
out_path->SetFormat("%s%s%s", m_package_root.Get(), str, ".cert");
}
}

View File

@@ -18,16 +18,16 @@
namespace ams::ncm {
PackageSystemUpdateTask::~PackageSystemUpdateTask() {
if (this->context_path.GetLength() > 0) {
fs::DeleteFile(this->context_path);
if (m_context_path.GetLength() > 0) {
fs::DeleteFile(m_context_path);
}
this->Inactivate();
}
void PackageSystemUpdateTask::Inactivate() {
if (this->gamecard_content_meta_database_active) {
if (m_gamecard_content_meta_database_active) {
InactivateContentMetaDatabase(StorageId::GameCard);
this->gamecard_content_meta_database_active = false;
m_gamecard_content_meta_database_active = false;
}
}
@@ -37,13 +37,13 @@ namespace ams::ncm {
/* Activate the game card content meta database. */
R_TRY(ActivateContentMetaDatabase(StorageId::GameCard));
this->gamecard_content_meta_database_active = true;
m_gamecard_content_meta_database_active = true;
auto meta_db_guard = SCOPE_GUARD { this->Inactivate(); };
/* Open the game card content meta database. */
OpenContentMetaDatabase(std::addressof(this->package_db), StorageId::GameCard);
OpenContentMetaDatabase(std::addressof(m_package_db), StorageId::GameCard);
ContentMetaDatabaseBuilder builder(std::addressof(this->package_db));
ContentMetaDatabaseBuilder builder(std::addressof(m_package_db));
/* Cleanup and build the content meta database. */
R_TRY(builder.Cleanup());
@@ -55,18 +55,18 @@ namespace ams::ncm {
auto context_guard = SCOPE_GUARD { fs::DeleteFile(context_path); };
/* Initialize data. */
R_TRY(this->data.Initialize(context_path));
R_TRY(m_data.Initialize(context_path));
/* Initialize PackageInstallTaskBase. */
u32 config = !requires_exfat_driver ? InstallConfig_SystemUpdate : InstallConfig_SystemUpdate | InstallConfig_RequiresExFatDriver;
R_TRY(PackageInstallTaskBase::Initialize(package_root, buffer, buffer_size, StorageId::BuiltInSystem, std::addressof(this->data), config));
R_TRY(PackageInstallTaskBase::Initialize(package_root, buffer, buffer_size, StorageId::BuiltInSystem, std::addressof(m_data), config));
/* Cancel guards. */
context_guard.Cancel();
meta_db_guard.Cancel();
/* Set the context path. */
this->context_path.Set(context_path);
m_context_path.Set(context_path);
return ResultSuccess();
}
@@ -109,7 +109,7 @@ namespace ams::ncm {
Result PackageSystemUpdateTask::PrepareInstallContentMetaData() {
/* Obtain a SystemUpdate key. */
ContentMetaKey key;
auto list_count = this->package_db.ListContentMeta(std::addressof(key), 1, ContentMetaType::SystemUpdate);
auto list_count = m_package_db.ListContentMeta(std::addressof(key), 1, ContentMetaType::SystemUpdate);
R_UNLESS(list_count.written > 0, ncm::ResultSystemUpdateNotFoundInPackage());
/* Get the content info for the key. */
@@ -130,7 +130,7 @@ namespace ams::ncm {
/* List content infos. */
s32 count;
ContentInfo info;
R_TRY(this->package_db.ListContentInfo(std::addressof(count), std::addressof(info), 1, key, ofs++));
R_TRY(m_package_db.ListContentInfo(std::addressof(count), std::addressof(info), 1, key, ofs++));
/* No content infos left to list. */
if (count == 0) {

View File

@@ -49,7 +49,7 @@ namespace ams::ncm {
}
void PlaceHolderAccessor::MakePath(PathString *out_placeholder_path, PlaceHolderId placeholder_id) const {
MakePlaceHolderFilePath(out_placeholder_path, placeholder_id, this->make_placeholder_path_func, *this->root_path);
MakePlaceHolderFilePath(out_placeholder_path, placeholder_id, m_make_placeholder_path_func, *m_root_path);
}
void PlaceHolderAccessor::MakeBaseDirectoryPath(PathString *out, const char *root_path) {
@@ -95,7 +95,7 @@ namespace ams::ncm {
}
bool PlaceHolderAccessor::LoadFromCache(fs::FileHandle *out_handle, PlaceHolderId placeholder_id) {
std::scoped_lock lk(this->cache_mutex);
std::scoped_lock lk(m_cache_mutex);
/* Attempt to find an entry in the cache. */
CacheEntry *entry = this->FindInCache(placeholder_id);
@@ -110,13 +110,13 @@ namespace ams::ncm {
}
void PlaceHolderAccessor::StoreToCache(PlaceHolderId placeholder_id, fs::FileHandle handle) {
std::scoped_lock lk(this->cache_mutex);
std::scoped_lock lk(m_cache_mutex);
/* Store placeholder id and file handle to a free entry. */
CacheEntry *entry = this->GetFreeEntry();
entry->id = placeholder_id;
entry->handle = handle;
entry->counter = this->cur_counter++;
entry->counter = m_cur_counter++;
}
void PlaceHolderAccessor::Invalidate(CacheEntry *entry) {
@@ -136,8 +136,8 @@ namespace ams::ncm {
/* Attempt to find a cache entry with the same placeholder id. */
for (size_t i = 0; i < MaxCacheEntries; i++) {
if (placeholder_id == this->caches[i].id) {
return std::addressof(this->caches[i]);
if (placeholder_id == m_caches[i].id) {
return std::addressof(m_caches[i]);
}
}
return nullptr;
@@ -146,16 +146,16 @@ namespace ams::ncm {
PlaceHolderAccessor::CacheEntry *PlaceHolderAccessor::GetFreeEntry() {
/* Try to find an already free entry. */
for (size_t i = 0; i < MaxCacheEntries; i++) {
if (this->caches[i].id == InvalidPlaceHolderId) {
return std::addressof(this->caches[i]);
if (m_caches[i].id == InvalidPlaceHolderId) {
return std::addressof(m_caches[i]);
}
}
/* Get the oldest entry. */
CacheEntry *entry = std::addressof(this->caches[0]);
CacheEntry *entry = std::addressof(m_caches[0]);
for (size_t i = 1; i < MaxCacheEntries; i++) {
if (entry->counter < this->caches[i].counter) {
entry = std::addressof(this->caches[i]);
if (entry->counter < m_caches[i].counter) {
entry = std::addressof(m_caches[i]);
}
}
this->Invalidate(entry);
@@ -164,7 +164,7 @@ namespace ams::ncm {
void PlaceHolderAccessor::GetPath(PathString *placeholder_path, PlaceHolderId placeholder_id) {
{
std::scoped_lock lock(this->cache_mutex);
std::scoped_lock lock(m_cache_mutex);
this->Invalidate(this->FindInCache(placeholder_id));
}
this->MakePath(placeholder_path, placeholder_id);
@@ -210,7 +210,7 @@ namespace ams::ncm {
ON_SCOPE_EXIT { this->StoreToCache(placeholder_id, file); };
/* Write data to the placeholder file. */
return fs::WriteFile(file, offset, buffer, size, this->delay_flush ? fs::WriteOption::Flush : fs::WriteOption::None);
return fs::WriteFile(file, offset, buffer, size, m_delay_flush ? fs::WriteOption::Flush : fs::WriteOption::None);
}
Result PlaceHolderAccessor::SetPlaceHolderFileSize(PlaceHolderId placeholder_id, s64 size) {
@@ -246,7 +246,7 @@ namespace ams::ncm {
void PlaceHolderAccessor::InvalidateAll() {
/* Invalidate all cache entries. */
for (auto &entry : this->caches) {
for (auto &entry : m_caches) {
if (entry.id != InvalidPlaceHolderId) {
this->Invalidate(std::addressof(entry));
}

View File

@@ -20,21 +20,20 @@ namespace ams::ncm {
class PlaceHolderAccessor {
private:
class CacheEntry {
public:
PlaceHolderId id;
fs::FileHandle handle;
u64 counter;
struct CacheEntry {
PlaceHolderId id;
fs::FileHandle handle;
u64 counter;
};
static constexpr size_t MaxCacheEntries = 0x2;
private:
std::array<CacheEntry, MaxCacheEntries> caches;
PathString *root_path;
u64 cur_counter;
os::SdkMutex cache_mutex;
MakePlaceHolderPathFunction make_placeholder_path_func;
bool delay_flush;
std::array<CacheEntry, MaxCacheEntries> m_caches;
PathString *m_root_path;
u64 m_cur_counter;
os::SdkMutex m_cache_mutex;
MakePlaceHolderPathFunction m_make_placeholder_path_func;
bool m_delay_flush;
private:
Result Open(fs::FileHandle *out_handle, PlaceHolderId placeholder_id);
bool LoadFromCache(fs::FileHandle *out_handle, PlaceHolderId placeholder_id);
@@ -43,9 +42,9 @@ namespace ams::ncm {
CacheEntry *FindInCache(PlaceHolderId placeholder_id);
CacheEntry *GetFreeEntry();;
public:
PlaceHolderAccessor() : cur_counter(0), cache_mutex(), delay_flush(false) {
PlaceHolderAccessor() : m_cur_counter(0), m_cache_mutex(), m_delay_flush(false) {
for (size_t i = 0; i < MaxCacheEntries; i++) {
caches[i].id = InvalidPlaceHolderId;
m_caches[i].id = InvalidPlaceHolderId;
}
}
@@ -56,9 +55,9 @@ namespace ams::ncm {
public:
/* API. */
void Initialize(PathString *root, MakePlaceHolderPathFunction path_func, bool delay_flush) {
this->root_path = root;
this->make_placeholder_path_func = path_func;
this->delay_flush = delay_flush;
m_root_path = root;
m_make_placeholder_path_func = path_func;
m_delay_flush = delay_flush;
}
Result CreatePlaceHolderFile(PlaceHolderId placeholder_id, s64 size);
@@ -73,7 +72,7 @@ namespace ams::ncm {
void InvalidateAll();
Result EnsurePlaceHolderDirectory(PlaceHolderId placeholder_id);
size_t GetHierarchicalDirectoryDepth() const { return GetHierarchicalPlaceHolderDirectoryDepth(this->make_placeholder_path_func); }
size_t GetHierarchicalDirectoryDepth() const { return GetHierarchicalPlaceHolderDirectoryDepth(m_make_placeholder_path_func); }
};
}

View File

@@ -55,8 +55,8 @@ namespace ams::ncm {
Result ReadOnlyContentStorageImpl::Initialize(const char *path, MakeContentPathFunction content_path_func) {
R_TRY(this->EnsureEnabled());
this->root_path.Set(path);
this->make_content_path_func = content_path_func;
m_root_path.Set(path);
m_make_content_path_func = content_path_func;
return ResultSuccess();
}
@@ -100,7 +100,7 @@ namespace ams::ncm {
/* Make the content path. */
PathString content_path;
MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path);
MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path);
/* Check if the file exists. */
bool has;
@@ -108,7 +108,7 @@ namespace ams::ncm {
/* If the file is absent, make the path for game card content meta and check presence again. */
if (!has) {
MakeGameCardContentMetaPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path);
MakeGameCardContentMetaPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path);
R_TRY(fs::HasFile(std::addressof(has), content_path));
}
@@ -121,7 +121,7 @@ namespace ams::ncm {
/* Make the path for game card content meta. */
PathString content_path;
MakeGameCardContentMetaPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path);
MakeGameCardContentMetaPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path);
/* Check if the file exists. */
bool has_file;
@@ -129,7 +129,7 @@ namespace ams::ncm {
/* If the file is absent, make the path for regular content. */
if (!has_file) {
MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path);
MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path);
}
/* Substitute mount name with the common mount name. */
@@ -169,7 +169,7 @@ namespace ams::ncm {
/* Open the file for the content id. */
fs::FileHandle file;
R_TRY(OpenContentIdFileImpl(std::addressof(file), content_id, this->make_content_path_func, this->root_path));
R_TRY(OpenContentIdFileImpl(std::addressof(file), content_id, m_make_content_path_func, m_root_path));
ON_SCOPE_EXIT { fs::CloseFile(file); };
/* Determine the file size. */
@@ -181,7 +181,7 @@ namespace ams::ncm {
}
Result ReadOnlyContentStorageImpl::DisableForcibly() {
this->disabled = true;
m_disabled = true;
return ResultSuccess();
}
@@ -202,7 +202,7 @@ namespace ams::ncm {
/* Open the file for the content id. */
fs::FileHandle file;
R_TRY(OpenContentIdFileImpl(std::addressof(file), content_id, this->make_content_path_func, this->root_path));
R_TRY(OpenContentIdFileImpl(std::addressof(file), content_id, m_make_content_path_func, m_root_path));
ON_SCOPE_EXIT { fs::CloseFile(file); };
/* Read from the given offset up to the given size. */

View File

@@ -21,23 +21,23 @@ namespace ams::ncm {
NON_COPYABLE(RegisteredPath);
NON_MOVEABLE(RegisteredPath);
private:
ContentId content_id;
Path path;
ContentId m_content_id;
Path m_path;
public:
RegisteredPath(const ncm::ContentId &content_id, const Path &p) : content_id(content_id), path(p) {
RegisteredPath(const ncm::ContentId &content_id, const Path &p) : m_content_id(content_id), m_path(p) {
/* ... */
}
ncm::ContentId GetContentId() const {
return this->content_id;
return m_content_id;
}
void GetPath(Path *out) const {
*out = this->path;
*out = m_path;
}
void SetPath(const Path &path) {
this->path = path;
m_path = path;
}
};
@@ -46,10 +46,10 @@ namespace ams::ncm {
}
Result RegisteredHostContent::RegisterPath(const ncm::ContentId &content_id, const ncm::Path &path) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Replace the path of any existing entries. */
for (auto &registered_path : this->path_list) {
for (auto &registered_path : m_path_list) {
if (registered_path.GetContentId() == content_id) {
registered_path.SetPath(path);
return ResultSuccess();
@@ -61,15 +61,15 @@ namespace ams::ncm {
R_UNLESS(registered_path != nullptr, ncm::ResultBufferInsufficient());
/* Insert the path into the list. */
this->path_list.push_back(*registered_path);
m_path_list.push_back(*registered_path);
return ResultSuccess();
}
Result RegisteredHostContent::GetPath(Path *out, const ncm::ContentId &content_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Obtain the path of the content. */
for (const auto &registered_path : this->path_list) {
for (const auto &registered_path : m_path_list) {
if (registered_path.GetContentId() == content_id) {
registered_path.GetPath(out);
return ResultSuccess();
@@ -80,9 +80,9 @@ namespace ams::ncm {
void RegisteredHostContent::ClearPaths() {
/* Remove all paths. */
for (auto it = this->path_list.begin(); it != this->path_list.end(); /* ... */) {
for (auto it = m_path_list.begin(); it != m_path_list.end(); /* ... */) {
auto *obj = std::addressof(*it);
it = this->path_list.erase(it);
it = m_path_list.erase(it);
delete obj;
}
}

View File

@@ -20,11 +20,11 @@ namespace ams::ncm {
class RemoteContentMetaDatabaseImpl {
private:
::NcmContentMetaDatabase srv;
::NcmContentMetaDatabase m_srv;
public:
RemoteContentMetaDatabaseImpl(::NcmContentMetaDatabase &db) : srv(db) { /* ... */ }
RemoteContentMetaDatabaseImpl(::NcmContentMetaDatabase &db) : m_srv(db) { /* ... */ }
~RemoteContentMetaDatabaseImpl() { ::ncmContentMetaDatabaseClose(std::addressof(srv)); }
~RemoteContentMetaDatabaseImpl() { ::ncmContentMetaDatabaseClose(std::addressof(m_srv)); }
private:
ALWAYS_INLINE ::NcmContentMetaKey *Convert(ContentMetaKey *k) {
static_assert(sizeof(ContentMetaKey) == sizeof(::NcmContentMetaKey));
@@ -72,88 +72,88 @@ namespace ams::ncm {
}
public:
Result Set(const ContentMetaKey &key, const sf::InBuffer &value) {
return ncmContentMetaDatabaseSet(std::addressof(this->srv), Convert(key), value.GetPointer(), value.GetSize());
return ncmContentMetaDatabaseSet(std::addressof(m_srv), Convert(key), value.GetPointer(), value.GetSize());
}
Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, const sf::OutBuffer &out_value) {
return ncmContentMetaDatabaseGet(std::addressof(this->srv), Convert(key), out_size.GetPointer(), out_value.GetPointer(), out_value.GetSize());
return ncmContentMetaDatabaseGet(std::addressof(m_srv), Convert(key), out_size.GetPointer(), out_value.GetPointer(), out_value.GetSize());
}
Result Remove(const ContentMetaKey &key) {
return ncmContentMetaDatabaseRemove(std::addressof(this->srv), Convert(key));
return ncmContentMetaDatabaseRemove(std::addressof(m_srv), Convert(key));
}
Result GetContentIdByType(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type) {
return ncmContentMetaDatabaseGetContentIdByType(std::addressof(this->srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type));
return ncmContentMetaDatabaseGetContentIdByType(std::addressof(m_srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type));
}
Result ListContentInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentInfo> &out_info, const ContentMetaKey &key, s32 offset) {
return ncmContentMetaDatabaseListContentInfo(std::addressof(this->srv), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), Convert(key), offset);
return ncmContentMetaDatabaseListContentInfo(std::addressof(m_srv), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), Convert(key), offset);
}
Result List(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaKey> &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) {
return ncmContentMetaDatabaseList(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), static_cast<::NcmContentMetaType>(meta_type), application_id.value, min, max, static_cast<::NcmContentInstallType>(install_type));
return ncmContentMetaDatabaseList(std::addressof(m_srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), static_cast<::NcmContentMetaType>(meta_type), application_id.value, min, max, static_cast<::NcmContentInstallType>(install_type));
}
Result GetLatestContentMetaKey(sf::Out<ContentMetaKey> out_key, u64 id) {
return ncmContentMetaDatabaseGetLatestContentMetaKey(std::addressof(this->srv), Convert(out_key.GetPointer()), static_cast<u64>(id));
return ncmContentMetaDatabaseGetLatestContentMetaKey(std::addressof(m_srv), Convert(out_key.GetPointer()), static_cast<u64>(id));
}
Result ListApplication(sf::Out<s32> out_entries_total, sf::Out<s32> out_entries_written, const sf::OutArray<ApplicationContentMetaKey> &out_keys, ContentMetaType meta_type) {
return ncmContentMetaDatabaseListApplication(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_keys.GetPointer()), out_keys.GetSize(), static_cast<::NcmContentMetaType>(meta_type));
return ncmContentMetaDatabaseListApplication(std::addressof(m_srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_keys.GetPointer()), out_keys.GetSize(), static_cast<::NcmContentMetaType>(meta_type));
}
Result Has(sf::Out<bool> out, const ContentMetaKey &key) {
return ncmContentMetaDatabaseHas(std::addressof(this->srv), out.GetPointer(), Convert(key));
return ncmContentMetaDatabaseHas(std::addressof(m_srv), out.GetPointer(), Convert(key));
}
Result HasAll(sf::Out<bool> out, const sf::InArray<ContentMetaKey> &keys) {
return ncmContentMetaDatabaseHasAll(std::addressof(this->srv), out.GetPointer(), Convert(keys.GetPointer()), keys.GetSize());
return ncmContentMetaDatabaseHasAll(std::addressof(m_srv), out.GetPointer(), Convert(keys.GetPointer()), keys.GetSize());
}
Result GetSize(sf::Out<u64> out_size, const ContentMetaKey &key) {
return ncmContentMetaDatabaseGetSize(std::addressof(this->srv), out_size.GetPointer(), Convert(key));
return ncmContentMetaDatabaseGetSize(std::addressof(m_srv), out_size.GetPointer(), Convert(key));
}
Result GetRequiredSystemVersion(sf::Out<u32> out_version, const ContentMetaKey &key) {
return ncmContentMetaDatabaseGetRequiredSystemVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key));
return ncmContentMetaDatabaseGetRequiredSystemVersion(std::addressof(m_srv), out_version.GetPointer(), Convert(key));
}
Result GetPatchId(sf::Out<PatchId> out_patch_id, const ContentMetaKey &key) {
return ncmContentMetaDatabaseGetPatchId(std::addressof(this->srv), reinterpret_cast<u64 *>(out_patch_id.GetPointer()), Convert(key));
return ncmContentMetaDatabaseGetPatchId(std::addressof(m_srv), reinterpret_cast<u64 *>(out_patch_id.GetPointer()), Convert(key));
}
Result DisableForcibly() {
return ncmContentMetaDatabaseDisableForcibly(std::addressof(this->srv));
return ncmContentMetaDatabaseDisableForcibly(std::addressof(m_srv));
}
Result LookupOrphanContent(const sf::OutArray<bool> &out_orphaned, const sf::InArray<ContentId> &content_ids) {
return ncmContentMetaDatabaseLookupOrphanContent(std::addressof(this->srv), out_orphaned.GetPointer(), Convert(content_ids.GetPointer()), std::min(out_orphaned.GetSize(), content_ids.GetSize()));
return ncmContentMetaDatabaseLookupOrphanContent(std::addressof(m_srv), out_orphaned.GetPointer(), Convert(content_ids.GetPointer()), std::min(out_orphaned.GetSize(), content_ids.GetSize()));
}
Result Commit() {
return ncmContentMetaDatabaseCommit(std::addressof(this->srv));
return ncmContentMetaDatabaseCommit(std::addressof(m_srv));
}
Result HasContent(sf::Out<bool> out, const ContentMetaKey &key, const ContentId &content_id) {
return ncmContentMetaDatabaseHasContent(std::addressof(this->srv), out.GetPointer(), Convert(key), Convert(content_id));
return ncmContentMetaDatabaseHasContent(std::addressof(m_srv), out.GetPointer(), Convert(key), Convert(content_id));
}
Result ListContentMetaInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentMetaInfo> &out_meta_info, const ContentMetaKey &key, s32 offset) {
return ncmContentMetaDatabaseListContentMetaInfo(std::addressof(this->srv), out_entries_written.GetPointer(), out_meta_info.GetPointer(), out_meta_info.GetSize(), Convert(key), offset);
return ncmContentMetaDatabaseListContentMetaInfo(std::addressof(m_srv), out_entries_written.GetPointer(), out_meta_info.GetPointer(), out_meta_info.GetSize(), Convert(key), offset);
}
Result GetAttributes(sf::Out<u8> out_attributes, const ContentMetaKey &key) {
static_assert(sizeof(ContentMetaAttribute) == sizeof(u8));
return ncmContentMetaDatabaseGetAttributes(std::addressof(this->srv), Convert(key), out_attributes.GetPointer());
return ncmContentMetaDatabaseGetAttributes(std::addressof(m_srv), Convert(key), out_attributes.GetPointer());
}
Result GetRequiredApplicationVersion(sf::Out<u32> out_version, const ContentMetaKey &key) {
return ncmContentMetaDatabaseGetRequiredApplicationVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key));
return ncmContentMetaDatabaseGetRequiredApplicationVersion(std::addressof(m_srv), out_version.GetPointer(), Convert(key));
}
Result GetContentIdByTypeAndIdOffset(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) {
return ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(std::addressof(this->srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type), id_offset);
return ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(std::addressof(m_srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type), id_offset);
}
Result GetCount(sf::Out<u32> out_count) {

View File

@@ -20,11 +20,11 @@ namespace ams::ncm {
class RemoteContentStorageImpl {
private:
::NcmContentStorage srv;
::NcmContentStorage m_srv;
public:
RemoteContentStorageImpl(::NcmContentStorage &cs) : srv(cs) { /* ... */ }
RemoteContentStorageImpl(::NcmContentStorage &cs) : m_srv(cs) { /* ... */ }
~RemoteContentStorageImpl() { ::ncmContentStorageClose(std::addressof(srv)); }
~RemoteContentStorageImpl() { ::ncmContentStorageClose(std::addressof(m_srv)); }
private:
ALWAYS_INLINE ::NcmPlaceHolderId *Convert(PlaceHolderId *p) {
static_assert(sizeof(PlaceHolderId) == sizeof(::NcmPlaceHolderId));
@@ -57,86 +57,86 @@ namespace ams::ncm {
}
public:
Result GeneratePlaceHolderId(sf::Out<PlaceHolderId> out) {
return ncmContentStorageGeneratePlaceHolderId(std::addressof(this->srv), Convert(out.GetPointer()));
return ncmContentStorageGeneratePlaceHolderId(std::addressof(m_srv), Convert(out.GetPointer()));
}
Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) {
static_assert(alignof(ContentId) < alignof(PlaceHolderId));
return ncmContentStorageCreatePlaceHolder(std::addressof(this->srv), Convert(content_id), Convert(placeholder_id), size);
return ncmContentStorageCreatePlaceHolder(std::addressof(m_srv), Convert(content_id), Convert(placeholder_id), size);
}
Result DeletePlaceHolder(PlaceHolderId placeholder_id) {
return ncmContentStorageDeletePlaceHolder(std::addressof(this->srv), Convert(placeholder_id));
return ncmContentStorageDeletePlaceHolder(std::addressof(m_srv), Convert(placeholder_id));
}
Result HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) {
return ncmContentStorageHasPlaceHolder(std::addressof(this->srv), out.GetPointer(), Convert(placeholder_id));
return ncmContentStorageHasPlaceHolder(std::addressof(m_srv), out.GetPointer(), Convert(placeholder_id));
}
Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data) {
return ncmContentStorageWritePlaceHolder(std::addressof(this->srv), Convert(placeholder_id), offset, data.GetPointer(), data.GetSize());
return ncmContentStorageWritePlaceHolder(std::addressof(m_srv), Convert(placeholder_id), offset, data.GetPointer(), data.GetSize());
}
Result Register(PlaceHolderId placeholder_id, ContentId content_id) {
static_assert(alignof(ContentId) < alignof(PlaceHolderId));
return ncmContentStorageRegister(std::addressof(this->srv), Convert(content_id), Convert(placeholder_id));
return ncmContentStorageRegister(std::addressof(m_srv), Convert(content_id), Convert(placeholder_id));
}
Result Delete(ContentId content_id) {
return ncmContentStorageDelete(std::addressof(this->srv), Convert(content_id));
return ncmContentStorageDelete(std::addressof(m_srv), Convert(content_id));
}
Result Has(sf::Out<bool> out, ContentId content_id) {
return ncmContentStorageHas(std::addressof(this->srv), out.GetPointer(), Convert(content_id));
return ncmContentStorageHas(std::addressof(m_srv), out.GetPointer(), Convert(content_id));
}
Result GetPath(sf::Out<Path> out, ContentId content_id) {
return ncmContentStorageGetPath(std::addressof(this->srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(content_id));
return ncmContentStorageGetPath(std::addressof(m_srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(content_id));
}
Result GetPlaceHolderPath(sf::Out<Path> out, PlaceHolderId placeholder_id) {
return ncmContentStorageGetPlaceHolderPath(std::addressof(this->srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(placeholder_id));
return ncmContentStorageGetPlaceHolderPath(std::addressof(m_srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(placeholder_id));
}
Result CleanupAllPlaceHolder() {
return ncmContentStorageCleanupAllPlaceHolder(std::addressof(this->srv));
return ncmContentStorageCleanupAllPlaceHolder(std::addressof(m_srv));
}
Result ListPlaceHolder(sf::Out<s32> out_count, const sf::OutArray<PlaceHolderId> &out_buf) {
return ncmContentStorageListPlaceHolder(std::addressof(this->srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer());
return ncmContentStorageListPlaceHolder(std::addressof(m_srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer());
}
Result GetContentCount(sf::Out<s32> out_count) {
return ncmContentStorageGetContentCount(std::addressof(this->srv), out_count.GetPointer());
return ncmContentStorageGetContentCount(std::addressof(m_srv), out_count.GetPointer());
}
Result ListContentId(sf::Out<s32> out_count, const sf::OutArray<ContentId> &out_buf, s32 offset) {
return ncmContentStorageListContentId(std::addressof(this->srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer(), offset);
return ncmContentStorageListContentId(std::addressof(m_srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer(), offset);
}
Result GetSizeFromContentId(sf::Out<s64> out_size, ContentId content_id) {
return ncmContentStorageGetSizeFromContentId(std::addressof(this->srv), out_size.GetPointer(), Convert(content_id));
return ncmContentStorageGetSizeFromContentId(std::addressof(m_srv), out_size.GetPointer(), Convert(content_id));
}
Result DisableForcibly() {
return ncmContentStorageDisableForcibly(std::addressof(this->srv));
return ncmContentStorageDisableForcibly(std::addressof(m_srv));
}
Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) {
return ncmContentStorageRevertToPlaceHolder(std::addressof(this->srv), Convert(placeholder_id), Convert(old_content_id), Convert(new_content_id));
return ncmContentStorageRevertToPlaceHolder(std::addressof(m_srv), Convert(placeholder_id), Convert(old_content_id), Convert(new_content_id));
}
Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) {
return ncmContentStorageSetPlaceHolderSize(std::addressof(this->srv), Convert(placeholder_id), size);
return ncmContentStorageSetPlaceHolderSize(std::addressof(m_srv), Convert(placeholder_id), size);
}
Result ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) {
return ncmContentStorageReadContentIdFile(std::addressof(this->srv), buf.GetPointer(), buf.GetSize(), Convert(content_id), offset);
return ncmContentStorageReadContentIdFile(std::addressof(m_srv), buf.GetPointer(), buf.GetSize(), Convert(content_id), offset);
}
Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
::NcmRightsId rights_id;
R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(this->srv), std::addressof(rights_id), Convert(placeholder_id)));
R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(m_srv), std::addressof(rights_id), Convert(placeholder_id)));
static_assert(sizeof(*out_rights_id.GetPointer()) <= sizeof(rights_id));
std::memcpy(out_rights_id.GetPointer(), std::addressof(rights_id), sizeof(*out_rights_id.GetPointer()));
@@ -145,7 +145,7 @@ namespace ams::ncm {
Result GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id) {
::NcmRightsId rights_id;
R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(this->srv), std::addressof(rights_id), Convert(placeholder_id)));
R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(m_srv), std::addressof(rights_id), Convert(placeholder_id)));
static_assert(sizeof(*out_rights_id.GetPointer()) <= sizeof(rights_id));
std::memcpy(out_rights_id.GetPointer(), std::addressof(rights_id), sizeof(*out_rights_id.GetPointer()));
@@ -154,7 +154,7 @@ namespace ams::ncm {
Result GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) {
::NcmRightsId rights_id;
R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(this->srv), std::addressof(rights_id), Convert(content_id)));
R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(m_srv), std::addressof(rights_id), Convert(content_id)));
static_assert(sizeof(*out_rights_id.GetPointer()) <= sizeof(rights_id));
std::memcpy(out_rights_id.GetPointer(), std::addressof(rights_id), sizeof(*out_rights_id.GetPointer()));
@@ -163,7 +163,7 @@ namespace ams::ncm {
Result GetRightsIdFromContentId(sf::Out<ncm::RightsId> out_rights_id, ContentId content_id) {
::NcmRightsId rights_id;
R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(this->srv), std::addressof(rights_id), Convert(content_id)));
R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(m_srv), std::addressof(rights_id), Convert(content_id)));
static_assert(sizeof(*out_rights_id.GetPointer()) <= sizeof(rights_id));
std::memcpy(out_rights_id.GetPointer(), std::addressof(rights_id), sizeof(*out_rights_id.GetPointer()));
@@ -171,41 +171,41 @@ namespace ams::ncm {
}
Result WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) {
return ncmContentStorageWriteContentForDebug(std::addressof(this->srv), Convert(content_id), offset, data.GetPointer(), data.GetSize());
return ncmContentStorageWriteContentForDebug(std::addressof(m_srv), Convert(content_id), offset, data.GetPointer(), data.GetSize());
}
Result GetFreeSpaceSize(sf::Out<s64> out_size) {
return ncmContentStorageGetFreeSpaceSize(std::addressof(this->srv), out_size.GetPointer());
return ncmContentStorageGetFreeSpaceSize(std::addressof(m_srv), out_size.GetPointer());
}
Result GetTotalSpaceSize(sf::Out<s64> out_size) {
return ncmContentStorageGetTotalSpaceSize(std::addressof(this->srv), out_size.GetPointer());
return ncmContentStorageGetTotalSpaceSize(std::addressof(m_srv), out_size.GetPointer());
}
Result FlushPlaceHolder() {
return ncmContentStorageFlushPlaceHolder(std::addressof(this->srv));
return ncmContentStorageFlushPlaceHolder(std::addressof(m_srv));
}
Result GetSizeFromPlaceHolderId(sf::Out<s64> out_size, PlaceHolderId placeholder_id) {
return ncmContentStorageGetSizeFromPlaceHolderId(std::addressof(this->srv), out_size.GetPointer(), Convert(placeholder_id));
return ncmContentStorageGetSizeFromPlaceHolderId(std::addressof(m_srv), out_size.GetPointer(), Convert(placeholder_id));
}
Result RepairInvalidFileAttribute() {
return ncmContentStorageRepairInvalidFileAttribute(std::addressof(this->srv));
return ncmContentStorageRepairInvalidFileAttribute(std::addressof(m_srv));
}
Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) {
static_assert(sizeof(::NcmRightsId) == sizeof(ncm::RightsId));
::NcmRightsId *out = reinterpret_cast<::NcmRightsId *>(out_rights_id.GetPointer());
return ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(std::addressof(this->srv), out, Convert(placeholder_id), Convert(cache_content_id));
return ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(std::addressof(m_srv), out, Convert(placeholder_id), Convert(cache_content_id));
}
Result RegisterPath(const ContentId &content_id, const Path &path) {
return ncmContentStorageRegisterPath(std::addressof(this->srv), Convert(content_id), path.str);
return ncmContentStorageRegisterPath(std::addressof(m_srv), Convert(content_id), path.str);
}
Result ClearRegisteredPath() {
return ncmContentStorageClearRegisteredPath(std::addressof(this->srv));
return ncmContentStorageClearRegisteredPath(std::addressof(m_srv));
}
};
static_assert(ncm::IsIContentStorage<RemoteContentStorageImpl>);

View File

@@ -20,38 +20,38 @@ namespace ams::ncm {
class SubmissionPackageInstallTask::Impl {
private:
fs::FileHandleStorage storage;
util::optional<impl::MountName> mount_name;
fs::FileHandleStorage m_storage;
util::optional<impl::MountName> m_mount_name;
public:
explicit Impl(fs::FileHandle file) : storage(file), mount_name(util::nullopt) { /* ... */ }
explicit Impl(fs::FileHandle file) : m_storage(file), m_mount_name(util::nullopt) { /* ... */ }
~Impl() {
if (this->mount_name) {
fs::fsa::Unregister(this->mount_name->str);
if (m_mount_name) {
fs::fsa::Unregister(m_mount_name->str);
}
}
Result Initialize() {
AMS_ASSERT(!this->mount_name);
AMS_ASSERT(!m_mount_name);
/* Allocate a partition file system. */
auto partition_file_system = std::make_unique<fssystem::PartitionFileSystem>();
R_UNLESS(partition_file_system != nullptr, ncm::ResultAllocationFailed());
/* Initialize the partition file system. */
R_TRY(partition_file_system->Initialize(std::addressof(this->storage)));
R_TRY(partition_file_system->Initialize(std::addressof(m_storage)));
/* Create a mount name and register the file system. */
auto mount_name = impl::CreateUniqueMountName();
R_TRY(fs::fsa::Register(mount_name.str, std::move(partition_file_system)));
/* Initialize members. */
this->mount_name = mount_name;
m_mount_name = mount_name;
return ResultSuccess();
}
const impl::MountName &GetMountName() const {
return *this->mount_name;
return *m_mount_name;
}
};
@@ -59,17 +59,17 @@ namespace ams::ncm {
SubmissionPackageInstallTask::~SubmissionPackageInstallTask() { /* ... */ }
Result SubmissionPackageInstallTask::Initialize(fs::FileHandle file, StorageId storage_id, void *buffer, size_t buffer_size, bool ignore_ticket) {
AMS_ASSERT(!this->impl);
AMS_ASSERT(!m_impl);
/* Allocate impl. */
this->impl.reset(new (std::nothrow) Impl(file));
R_UNLESS(this->impl != nullptr, ncm::ResultAllocationFailed());
m_impl.reset(new (std::nothrow) Impl(file));
R_UNLESS(m_impl != nullptr, ncm::ResultAllocationFailed());
/* Initialize impl. */
R_TRY(this->impl->Initialize());
R_TRY(m_impl->Initialize());
/* Initialize parent. N doesn't check the result. */
PackageInstallTask::Initialize(impl::GetRootDirectoryPath(this->impl->GetMountName()).str, storage_id, buffer, buffer_size, ignore_ticket);
PackageInstallTask::Initialize(impl::GetRootDirectoryPath(m_impl->GetMountName()).str, storage_id, buffer, buffer_size, ignore_ticket);
return ResultSuccess();
}