mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-01-07 04:47:58 +00:00
Universally use EnsureEnabled
This commit is contained in:
parent
cf06cb7628
commit
fac8acebba
8 changed files with 50 additions and 103 deletions
|
@ -179,15 +179,6 @@ namespace sts::ncm {
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ContentMetaDatabaseInterface::EnsureEnabled() {
|
|
||||||
if (this->disabled) {
|
|
||||||
return ResultNcmInvalidContentMetaDatabase;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResultSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Result ContentMetaDatabaseInterface::Set(ContentMetaKey key, InBuffer<u8> value) {
|
Result ContentMetaDatabaseInterface::Set(ContentMetaKey key, InBuffer<u8> value) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
R_TRY(this->EnsureEnabled());
|
R_TRY(this->EnsureEnabled());
|
||||||
|
|
|
@ -31,8 +31,6 @@ namespace sts::ncm {
|
||||||
private:
|
private:
|
||||||
Result GetContentIdByTypeImpl(ContentId* out, const ContentMetaKey& key, ContentType type, std::optional<u8> id_offset);
|
Result GetContentIdByTypeImpl(ContentId* out, const ContentMetaKey& key, ContentType type, std::optional<u8> id_offset);
|
||||||
Result GetLatestContentMetaKeyImpl(ContentMetaKey* out_key, TitleId tid);
|
Result GetLatestContentMetaKeyImpl(ContentMetaKey* out_key, TitleId tid);
|
||||||
protected:
|
|
||||||
Result EnsureEnabled();
|
|
||||||
public:
|
public:
|
||||||
virtual Result Set(ContentMetaKey key, InBuffer<u8> value) override;
|
virtual Result Set(ContentMetaKey key, InBuffer<u8> value) override;
|
||||||
virtual Result Get(Out<u64> out_size, ContentMetaKey key, OutBuffer<u8> out_value) override;
|
virtual Result Get(Out<u64> out_size, ContentMetaKey key, OutBuffer<u8> out_value) override;
|
||||||
|
|
|
@ -29,10 +29,7 @@ namespace sts::ncm {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ContentStorageInterface::Initialize(const char* root_path, MakeContentPathFunc content_path_func, MakePlaceHolderPathFunc placeholder_path_func, bool delay_flush) {
|
Result ContentStorageInterface::Initialize(const char* root_path, MakeContentPathFunc content_path_func, MakePlaceHolderPathFunc placeholder_path_func, bool delay_flush) {
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
R_TRY(CheckContentStorageDirectoriesExist(root_path));
|
R_TRY(CheckContentStorageDirectoriesExist(root_path));
|
||||||
const size_t root_path_len = strnlen(root_path, FS_MAX_PATH-1);
|
const size_t root_path_len = strnlen(root_path, FS_MAX_PATH-1);
|
||||||
|
|
||||||
|
@ -95,9 +92,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::GeneratePlaceHolderId(Out<PlaceHolderId> out) {
|
Result ContentStorageInterface::GeneratePlaceHolderId(Out<PlaceHolderId> out) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
sts::rnd::GenerateRandomBytes(out.GetPointer(), sizeof(NcmNcaId));
|
sts::rnd::GenerateRandomBytes(out.GetPointer(), sizeof(NcmNcaId));
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
|
@ -106,9 +101,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, u64 size) {
|
Result ContentStorageInterface::CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, u64 size) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char content_path[FS_MAX_PATH] = {0};
|
char content_path[FS_MAX_PATH] = {0};
|
||||||
this->GetContentPath(content_path, content_id);
|
this->GetContentPath(content_path, content_id);
|
||||||
|
@ -122,9 +115,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::DeletePlaceHolder(PlaceHolderId placeholder_id) {
|
Result ContentStorageInterface::DeletePlaceHolder(PlaceHolderId placeholder_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->placeholder_accessor.Delete(placeholder_id);
|
return this->placeholder_accessor.Delete(placeholder_id);
|
||||||
R_DEBUG_END
|
R_DEBUG_END
|
||||||
|
@ -132,9 +123,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::HasPlaceHolder(Out<bool> out, PlaceHolderId placeholder_id) {
|
Result ContentStorageInterface::HasPlaceHolder(Out<bool> out, PlaceHolderId placeholder_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char placeholder_path[FS_MAX_PATH] = {0};
|
char placeholder_path[FS_MAX_PATH] = {0};
|
||||||
this->placeholder_accessor.GetPlaceHolderPath(placeholder_path, placeholder_id);
|
this->placeholder_accessor.GetPlaceHolderPath(placeholder_path, placeholder_id);
|
||||||
|
@ -154,9 +143,7 @@ namespace sts::ncm {
|
||||||
return ResultNcmInvalidOffset;
|
return ResultNcmInvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
FILE* f = nullptr;
|
FILE* f = nullptr;
|
||||||
|
|
||||||
|
@ -199,10 +186,7 @@ namespace sts::ncm {
|
||||||
Result ContentStorageInterface::Register(PlaceHolderId placeholder_id, ContentId content_id) {
|
Result ContentStorageInterface::Register(PlaceHolderId placeholder_id, ContentId content_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
this->ClearContentCache();
|
this->ClearContentCache();
|
||||||
|
R_TRY(this->EnsureEnabled());
|
||||||
if (this->disabled) {
|
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char placeholder_path[FS_MAX_PATH] = {0};
|
char placeholder_path[FS_MAX_PATH] = {0};
|
||||||
char content_path[FS_MAX_PATH] = {0};
|
char content_path[FS_MAX_PATH] = {0};
|
||||||
|
@ -227,9 +211,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::Delete(ContentId content_id) {
|
Result ContentStorageInterface::Delete(ContentId content_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->ClearContentCache();
|
this->ClearContentCache();
|
||||||
char content_path[FS_MAX_PATH] = {0};
|
char content_path[FS_MAX_PATH] = {0};
|
||||||
|
@ -249,9 +231,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::Has(Out<bool> out, ContentId content_id) {
|
Result ContentStorageInterface::Has(Out<bool> out, ContentId content_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char content_path[FS_MAX_PATH] = {0};
|
char content_path[FS_MAX_PATH] = {0};
|
||||||
this->GetContentPath(content_path, content_id);
|
this->GetContentPath(content_path, content_id);
|
||||||
|
@ -266,9 +246,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::GetPath(OutPointerWithServerSize<lr::Path, 0x1> out, ContentId content_id) {
|
Result ContentStorageInterface::GetPath(OutPointerWithServerSize<lr::Path, 0x1> out, ContentId content_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char content_path[FS_MAX_PATH] = {0};
|
char content_path[FS_MAX_PATH] = {0};
|
||||||
char common_path[FS_MAX_PATH] = {0};
|
char common_path[FS_MAX_PATH] = {0};
|
||||||
|
@ -282,9 +260,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::GetPlaceHolderPath(OutPointerWithServerSize<lr::Path, 0x1> out, PlaceHolderId placeholder_id) {
|
Result ContentStorageInterface::GetPlaceHolderPath(OutPointerWithServerSize<lr::Path, 0x1> out, PlaceHolderId placeholder_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char placeholder_path[FS_MAX_PATH] = {0};
|
char placeholder_path[FS_MAX_PATH] = {0};
|
||||||
char common_path[FS_MAX_PATH] = {0};
|
char common_path[FS_MAX_PATH] = {0};
|
||||||
|
@ -297,9 +273,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::CleanupAllPlaceHolder() {
|
Result ContentStorageInterface::CleanupAllPlaceHolder() {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char placeholder_root_path[FS_MAX_PATH] = {0};
|
char placeholder_root_path[FS_MAX_PATH] = {0};
|
||||||
this->placeholder_accessor.ClearAllCaches();
|
this->placeholder_accessor.ClearAllCaches();
|
||||||
|
@ -319,9 +293,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::ListPlaceHolder(Out<u32> out_count, OutBuffer<PlaceHolderId> out_buf) {
|
Result ContentStorageInterface::ListPlaceHolder(Out<u32> out_count, OutBuffer<PlaceHolderId> out_buf) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char placeholder_root_path[FS_MAX_PATH] = {0};
|
char placeholder_root_path[FS_MAX_PATH] = {0};
|
||||||
this->placeholder_accessor.GetPlaceHolderRootPath(placeholder_root_path);
|
this->placeholder_accessor.GetPlaceHolderRootPath(placeholder_root_path);
|
||||||
|
@ -352,9 +324,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::GetContentCount(Out<u32> out_count) {
|
Result ContentStorageInterface::GetContentCount(Out<u32> out_count) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char content_root_path[FS_MAX_PATH] = {0};
|
char content_root_path[FS_MAX_PATH] = {0};
|
||||||
this->GetContentRootPath(content_root_path);
|
this->GetContentRootPath(content_root_path);
|
||||||
|
@ -383,9 +353,7 @@ namespace sts::ncm {
|
||||||
return ResultNcmInvalidOffset;
|
return ResultNcmInvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char content_root_path[FS_MAX_PATH] = {0};
|
char content_root_path[FS_MAX_PATH] = {0};
|
||||||
this->GetContentRootPath(content_root_path);
|
this->GetContentRootPath(content_root_path);
|
||||||
|
@ -436,9 +404,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::GetSizeFromContentId(Out<u64> out_size, ContentId content_id) {
|
Result ContentStorageInterface::GetSizeFromContentId(Out<u64> out_size, ContentId content_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char content_path[FS_MAX_PATH] = {0};
|
char content_path[FS_MAX_PATH] = {0};
|
||||||
this->GetContentPath(content_path, content_id);
|
this->GetContentPath(content_path, content_id);
|
||||||
|
@ -464,9 +430,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) {
|
Result ContentStorageInterface::RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char old_content_path[FS_MAX_PATH] = {0};
|
char old_content_path[FS_MAX_PATH] = {0};
|
||||||
char new_content_path[FS_MAX_PATH] = {0};
|
char new_content_path[FS_MAX_PATH] = {0};
|
||||||
|
@ -497,9 +461,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::SetPlaceHolderSize(PlaceHolderId placeholder_id, u64 size) {
|
Result ContentStorageInterface::SetPlaceHolderSize(PlaceHolderId placeholder_id, u64 size) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
R_TRY(this->placeholder_accessor.SetSize(placeholder_id, size));
|
R_TRY(this->placeholder_accessor.SetSize(placeholder_id, size));
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
|
@ -513,9 +475,7 @@ namespace sts::ncm {
|
||||||
return ResultNcmInvalidOffset;
|
return ResultNcmInvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char content_path[FS_MAX_PATH] = {0};
|
char content_path[FS_MAX_PATH] = {0};
|
||||||
this->GetContentPath(content_path, content_id);
|
this->GetContentPath(content_path, content_id);
|
||||||
|
@ -535,9 +495,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::GetRightsIdFromPlaceHolderId(Out<FsRightsId> out_rights_id, Out<u64> out_key_generation, PlaceHolderId placeholder_id) {
|
Result ContentStorageInterface::GetRightsIdFromPlaceHolderId(Out<FsRightsId> out_rights_id, Out<u64> out_key_generation, PlaceHolderId placeholder_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
FsRightsId rights_id = {0};
|
FsRightsId rights_id = {0};
|
||||||
u8 key_generation = 0;
|
u8 key_generation = 0;
|
||||||
|
@ -557,9 +515,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::GetRightsIdFromContentId(Out<FsRightsId> out_rights_id, Out<u64> out_key_generation, ContentId content_id) {
|
Result ContentStorageInterface::GetRightsIdFromContentId(Out<FsRightsId> out_rights_id, Out<u64> out_key_generation, ContentId content_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl::RightsIdCache* rights_id_cache = impl::GetRightsIdCache();
|
impl::RightsIdCache* rights_id_cache = impl::GetRightsIdCache();
|
||||||
|
|
||||||
|
@ -625,9 +581,7 @@ namespace sts::ncm {
|
||||||
return ResultNcmInvalidOffset;
|
return ResultNcmInvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_development = false;
|
bool is_development = false;
|
||||||
|
|
||||||
|
@ -706,9 +660,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::GetSizeFromPlaceHolderId(Out<u64> out_size, PlaceHolderId placeholder_id) {
|
Result ContentStorageInterface::GetSizeFromPlaceHolderId(Out<u64> out_size, PlaceHolderId placeholder_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool found_in_cache = false;
|
bool found_in_cache = false;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
@ -768,9 +720,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ContentStorageInterface::GetRightsIdFromPlaceHolderIdWithCache(Out<FsRightsId> out_rights_id, Out<u64> out_key_generation, PlaceHolderId placeholder_id, ContentId cache_content_id) {
|
Result ContentStorageInterface::GetRightsIdFromPlaceHolderIdWithCache(Out<FsRightsId> out_rights_id, Out<u64> out_key_generation, PlaceHolderId placeholder_id, ContentId cache_content_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl::RightsIdCache* rights_id_cache = impl::GetRightsIdCache();
|
impl::RightsIdCache* rights_id_cache = impl::GetRightsIdCache();
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,14 @@
|
||||||
|
|
||||||
namespace sts::ncm {
|
namespace sts::ncm {
|
||||||
|
|
||||||
|
Result IContentMetaDatabase::EnsureEnabled() {
|
||||||
|
if (this->disabled) {
|
||||||
|
return ResultNcmInvalidContentMetaDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
Result IContentMetaDatabase::Set(ContentMetaKey key, InBuffer<u8> value) {
|
Result IContentMetaDatabase::Set(ContentMetaKey key, InBuffer<u8> value) {
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ namespace sts::ncm {
|
||||||
sts::kvdb::MemoryKeyValueStore<ContentMetaKey>* kvs;
|
sts::kvdb::MemoryKeyValueStore<ContentMetaKey>* kvs;
|
||||||
char mount_name[16];
|
char mount_name[16];
|
||||||
bool disabled;
|
bool disabled;
|
||||||
|
protected:
|
||||||
|
Result EnsureEnabled();
|
||||||
public:
|
public:
|
||||||
IContentMetaDatabase(sts::kvdb::MemoryKeyValueStore<ContentMetaKey>* kvs) :
|
IContentMetaDatabase(sts::kvdb::MemoryKeyValueStore<ContentMetaKey>* kvs) :
|
||||||
kvs(kvs), disabled(false)
|
kvs(kvs), disabled(false)
|
||||||
|
|
|
@ -18,6 +18,14 @@
|
||||||
|
|
||||||
namespace sts::ncm {
|
namespace sts::ncm {
|
||||||
|
|
||||||
|
Result IContentStorage::EnsureEnabled() {
|
||||||
|
if (this->disabled) {
|
||||||
|
return ResultNcmInvalidContentStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
Result IContentStorage::GeneratePlaceHolderId(Out<PlaceHolderId> out) {
|
Result IContentStorage::GeneratePlaceHolderId(Out<PlaceHolderId> out) {
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,8 @@ namespace sts::ncm {
|
||||||
char root_path[FS_MAX_PATH-1];
|
char root_path[FS_MAX_PATH-1];
|
||||||
MakeContentPathFunc make_content_path_func;
|
MakeContentPathFunc make_content_path_func;
|
||||||
bool disabled;
|
bool disabled;
|
||||||
|
protected:
|
||||||
|
Result EnsureEnabled();
|
||||||
public:
|
public:
|
||||||
virtual Result GeneratePlaceHolderId(Out<PlaceHolderId> out);
|
virtual Result GeneratePlaceHolderId(Out<PlaceHolderId> out);
|
||||||
virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, u64 size);
|
virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, u64 size);
|
||||||
|
|
|
@ -24,9 +24,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ReadOnlyContentStorageInterface::Initialize(const char* root_path, MakeContentPathFunc content_path_func) {
|
Result ReadOnlyContentStorageInterface::Initialize(const char* root_path, MakeContentPathFunc content_path_func) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t root_path_len = strnlen(root_path, FS_MAX_PATH-1);
|
const size_t root_path_len = strnlen(root_path, FS_MAX_PATH-1);
|
||||||
|
|
||||||
|
@ -84,9 +82,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ReadOnlyContentStorageInterface::Has(Out<bool> out, ContentId content_id) {
|
Result ReadOnlyContentStorageInterface::Has(Out<bool> out, ContentId content_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char content_path[FS_MAX_PATH] = {0};
|
char content_path[FS_MAX_PATH] = {0};
|
||||||
this->make_content_path_func(content_path, content_id, this->root_path);
|
this->make_content_path_func(content_path, content_id, this->root_path);
|
||||||
|
@ -106,9 +102,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ReadOnlyContentStorageInterface::GetPath(OutPointerWithServerSize<lr::Path, 0x1> out, ContentId content_id) {
|
Result ReadOnlyContentStorageInterface::GetPath(OutPointerWithServerSize<lr::Path, 0x1> out, ContentId content_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char content_path[FS_MAX_PATH] = {0};
|
char content_path[FS_MAX_PATH] = {0};
|
||||||
char common_path[FS_MAX_PATH] = {0};
|
char common_path[FS_MAX_PATH] = {0};
|
||||||
|
@ -160,9 +154,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ReadOnlyContentStorageInterface::GetSizeFromContentId(Out<u64> out_size, ContentId content_id) {
|
Result ReadOnlyContentStorageInterface::GetSizeFromContentId(Out<u64> out_size, ContentId content_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char content_path[FS_MAX_PATH] = {0};
|
char content_path[FS_MAX_PATH] = {0};
|
||||||
bool is_content_file = false;
|
bool is_content_file = false;
|
||||||
|
@ -210,9 +202,7 @@ namespace sts::ncm {
|
||||||
return ResultNcmInvalidOffset;
|
return ResultNcmInvalidOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
char content_path[FS_MAX_PATH] = {0};
|
char content_path[FS_MAX_PATH] = {0};
|
||||||
bool is_content_file = false;
|
bool is_content_file = false;
|
||||||
|
@ -251,9 +241,7 @@ namespace sts::ncm {
|
||||||
|
|
||||||
Result ReadOnlyContentStorageInterface::GetRightsIdFromContentId(Out<FsRightsId> out_rights_id, Out<u64> out_key_generation, ContentId content_id) {
|
Result ReadOnlyContentStorageInterface::GetRightsIdFromContentId(Out<FsRightsId> out_rights_id, Out<u64> out_key_generation, ContentId content_id) {
|
||||||
R_DEBUG_START
|
R_DEBUG_START
|
||||||
if (this->disabled) {
|
R_TRY(this->EnsureEnabled());
|
||||||
return ResultNcmInvalidContentStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
FsRightsId rights_id = {0};
|
FsRightsId rights_id = {0};
|
||||||
u8 key_generation = 0;
|
u8 key_generation = 0;
|
||||||
|
|
Loading…
Reference in a new issue