mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-04-22 12:34:47 +00:00
ncm: use R_SUCCEED_IF
This commit is contained in:
parent
510a764350
commit
241697b8ba
4 changed files with 18 additions and 16 deletions
|
@ -81,7 +81,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Obtain the existing flags. */
|
||||
R_TRY(fs::GetSaveDataFlags(std::addressof(cur_flags), BuiltInSystemSaveDataId));
|
||||
|
||||
|
||||
/* Update the flags if needed. */
|
||||
if (cur_flags != BuiltInSystemSaveDataFlags) {
|
||||
R_TRY(fs::SetSaveDataFlags(BuiltInSystemSaveDataId, fs::SaveDataSpaceId::System, BuiltInSystemSaveDataFlags));
|
||||
|
@ -222,8 +222,8 @@ namespace ams::ncm {
|
|||
Result ContentManagerImpl::Initialize() {
|
||||
std::scoped_lock lk(this->mutex);
|
||||
|
||||
/* Already initialized. */
|
||||
R_UNLESS(!this->initialized, ResultSuccess());
|
||||
/* Check if we've already initialized. */
|
||||
R_SUCCEED_IF(this->initialized);
|
||||
|
||||
/* Clear storage id for all roots. */
|
||||
for (auto &root : this->content_storage_roots) {
|
||||
|
@ -289,7 +289,7 @@ namespace ams::ncm {
|
|||
|
||||
/* Ensure the content storage root's path exists. */
|
||||
R_TRY(impl::EnsureDirectoryRecursively(root->path));
|
||||
|
||||
|
||||
/* Initialize content and placeholder directories for the root. */
|
||||
R_TRY(ContentStorageImpl::InitializeBase(root->path));
|
||||
|
||||
|
@ -312,7 +312,7 @@ namespace ams::ncm {
|
|||
/* Ensure the content meta database root's path exists. */
|
||||
R_TRY(impl::EnsureDirectoryRecursively(root->path));
|
||||
|
||||
/* Commit our changes. */
|
||||
/* Commit our changes. */
|
||||
R_TRY(fs::CommitSaveData(root->mount_name));
|
||||
|
||||
return ResultSuccess();
|
||||
|
@ -342,7 +342,7 @@ namespace ams::ncm {
|
|||
|
||||
Result ContentManagerImpl::VerifyContentMetaDatabase(StorageId storage_id) {
|
||||
/* Game card content meta databases will always be valid. */
|
||||
R_UNLESS(storage_id != StorageId::GameCard, ResultSuccess());
|
||||
R_SUCCEED_IF(storage_id == StorageId::GameCard);
|
||||
|
||||
std::scoped_lock lk(this->mutex);
|
||||
|
||||
|
@ -441,7 +441,7 @@ namespace ams::ncm {
|
|||
R_TRY(this->GetContentStorageRoot(std::addressof(root), storage_id));
|
||||
|
||||
/* Check if the storage is already activated. */
|
||||
R_UNLESS(root->content_storage == nullptr, ResultSuccess());
|
||||
R_SUCCEED_IF(root->content_storage != nullptr);
|
||||
|
||||
/* Mount based on the storage type. */
|
||||
if (storage_id == StorageId::GameCard) {
|
||||
|
@ -511,7 +511,7 @@ namespace ams::ncm {
|
|||
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
|
||||
|
||||
/* Already activated. */
|
||||
R_UNLESS(root->content_meta_database == nullptr, ResultSuccess());
|
||||
R_SUCCEED_IF(root->content_meta_database != nullptr);
|
||||
|
||||
/* Make a new kvs. */
|
||||
root->kvs.emplace();
|
||||
|
|
|
@ -215,9 +215,12 @@ namespace ams::ncm {
|
|||
|
||||
/* Check if keys are present. */
|
||||
for (size_t i = 0; i < keys.GetSize(); i++) {
|
||||
/* Check if we have the current key. */
|
||||
bool has;
|
||||
R_TRY(this->Has(std::addressof(has), keys[i]));
|
||||
R_UNLESS(has, ResultSuccess());
|
||||
|
||||
/* If we don't, then we can early return because we don't have all. */
|
||||
R_SUCCEED_IF(!has);
|
||||
}
|
||||
|
||||
*out = true;
|
||||
|
@ -288,9 +291,6 @@ namespace ams::ncm {
|
|||
out_orphaned[i] = true;
|
||||
}
|
||||
|
||||
/* If key value store is empty, all content is orphaned. */
|
||||
R_UNLESS(this->kvs->GetCount() != 0, ResultSuccess());
|
||||
|
||||
auto IsOrphanedContent = [](const sf::InArray<ContentId> &list, const ncm::ContentId &id) ALWAYS_INLINE_LAMBDA {
|
||||
/* Check if any input content ids match our found content id. */
|
||||
for (size_t i = 0; i < list.GetSize(); i++) {
|
||||
|
|
|
@ -56,7 +56,8 @@ namespace ams::ncm {
|
|||
|
||||
template<typename F>
|
||||
Result TraverseDirectory(bool *out_should_continue, const char *root_path, int max_level, F f) {
|
||||
R_UNLESS(max_level > 0, ResultSuccess());
|
||||
/* If the level is zero, we're done. */
|
||||
R_SUCCEED_IF(max_level <= 0);
|
||||
|
||||
/* Retry traversal upon request. */
|
||||
bool retry_dir_read = true;
|
||||
|
@ -230,7 +231,8 @@ namespace ams::ncm {
|
|||
}
|
||||
|
||||
Result ContentStorageImpl::OpenContentIdFile(ContentId content_id) {
|
||||
R_UNLESS(this->cached_content_id != content_id, ResultSuccess());
|
||||
/* If the file is the currently cached one, we've nothing to do. */
|
||||
R_SUCCEED_IF(this->cached_content_id == content_id);
|
||||
|
||||
/* Close any cached file. */
|
||||
this->InvalidateFileCache();
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace ams::ncm {
|
|||
|
||||
Result PlaceHolderAccessor::Open(fs::FileHandle *out_handle, PlaceHolderId placeholder_id) {
|
||||
/* Try to load from the cache. */
|
||||
R_UNLESS(!this->LoadFromCache(out_handle, placeholder_id), ResultSuccess());
|
||||
R_SUCCEED_IF(this->LoadFromCache(out_handle, placeholder_id));
|
||||
|
||||
/* Make the path of the placeholder. */
|
||||
PathString placeholder_path;
|
||||
|
@ -231,7 +231,7 @@ namespace ams::ncm {
|
|||
/* Attempt to find the placeholder in the cache. */
|
||||
fs::FileHandle handle;
|
||||
auto found = this->LoadFromCache(std::addressof(handle), placeholder_id);
|
||||
|
||||
|
||||
if (found) {
|
||||
/* Renew the entry in the cache. */
|
||||
this->StoreToCache(placeholder_id, handle);
|
||||
|
|
Loading…
Add table
Reference in a new issue