Remove debug code (again)

This commit is contained in:
Adubbz
2019-08-08 18:24:56 +10:00
parent 1aa4c12e5e
commit 168447d80e
15 changed files with 0 additions and 565 deletions

View File

@@ -20,8 +20,6 @@
#include "ncm_make_path.hpp"
#include "ncm_utils.hpp"
#include "debug.hpp"
namespace sts::ncm {
ContentStorageInterface::~ContentStorageInterface() {
@@ -89,16 +87,13 @@ namespace sts::ncm {
}
Result ContentStorageInterface::GeneratePlaceHolderId(Out<PlaceHolderId> out) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
sts::rnd::GenerateRandomBytes(out.GetPointer(), sizeof(NcmNcaId));
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, u64 size) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
char content_path[FS_MAX_PATH] = {0};
@@ -108,19 +103,14 @@ namespace sts::ncm {
R_TRY(this->placeholder_accessor.Create(placeholder_id, size));
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::DeletePlaceHolder(PlaceHolderId placeholder_id) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
return this->placeholder_accessor.Delete(placeholder_id);
R_DEBUG_END
}
Result ContentStorageInterface::HasPlaceHolder(Out<bool> out, PlaceHolderId placeholder_id) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
char placeholder_path[FS_MAX_PATH] = {0};
@@ -131,11 +121,9 @@ namespace sts::ncm {
out.SetValue(has);
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::WritePlaceHolder(PlaceHolderId placeholder_id, u64 offset, InBuffer<u8> data) {
R_DEBUG_START
/* Offset is too large */
if (offset >> 0x3f != 0) {
return ResultNcmInvalidOffset;
@@ -144,11 +132,9 @@ namespace sts::ncm {
R_TRY(this->EnsureEnabled());
R_TRY(this->placeholder_accessor.Write(placeholder_id, offset, data.buffer, data.num_elements));
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::Register(PlaceHolderId placeholder_id, ContentId content_id) {
R_DEBUG_START
this->ClearContentCache();
R_TRY(this->EnsureEnabled());
@@ -170,11 +156,9 @@ namespace sts::ncm {
}
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::Delete(ContentId content_id) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
this->ClearContentCache();
@@ -190,11 +174,9 @@ namespace sts::ncm {
}
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::Has(Out<bool> out, ContentId content_id) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
char content_path[FS_MAX_PATH] = {0};
@@ -205,11 +187,9 @@ namespace sts::ncm {
out.SetValue(has);
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::GetPath(OutPointerWithServerSize<lr::Path, 0x1> out, ContentId content_id) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
char content_path[FS_MAX_PATH] = {0};
@@ -217,13 +197,10 @@ namespace sts::ncm {
this->GetContentPath(content_path, content_id);
R_TRY(ConvertToFsCommonPath(common_path, FS_MAX_PATH-1, content_path));
*out.pointer = common_path;
D_LOG("path: %s\n", common_path);
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::GetPlaceHolderPath(OutPointerWithServerSize<lr::Path, 0x1> out, PlaceHolderId placeholder_id) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
char placeholder_path[FS_MAX_PATH] = {0};
@@ -232,11 +209,9 @@ namespace sts::ncm {
R_TRY(ConvertToFsCommonPath(common_path, FS_MAX_PATH-1, placeholder_path));
*out.pointer = common_path;
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::CleanupAllPlaceHolder() {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
char placeholder_root_path[FS_MAX_PATH] = {0};
@@ -252,11 +227,9 @@ namespace sts::ncm {
}
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::ListPlaceHolder(Out<u32> out_count, OutBuffer<PlaceHolderId> out_buf) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
char placeholder_root_path[FS_MAX_PATH] = {0};
@@ -283,11 +256,9 @@ namespace sts::ncm {
out_count.SetValue(static_cast<u32>(entry_count));
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::GetContentCount(Out<u32> out_count) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
char content_root_path[FS_MAX_PATH] = {0};
@@ -308,11 +279,9 @@ namespace sts::ncm {
out_count.SetValue(content_count);
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::ListContentId(Out<u32> out_count, OutBuffer<ContentId> out_buf, u32 start_offset) {
R_DEBUG_START
if (start_offset >> 0x1f != 0) {
return ResultNcmInvalidOffset;
}
@@ -358,16 +327,13 @@ namespace sts::ncm {
for (size_t i = 0; i < entry_count; i++) {
char content_name[sizeof(ContentId)*2+1] = {0};
GetStringFromContentId(content_name, out_buf[i]);
D_LOG("content id: %s.nca\n", content_name);
}
out_count.SetValue(static_cast<u32>(entry_count));
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::GetSizeFromContentId(Out<u64> out_size, ContentId content_id) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
char content_path[FS_MAX_PATH] = {0};
@@ -380,20 +346,16 @@ namespace sts::ncm {
out_size.SetValue(st.st_size);
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::DisableForcibly() {
R_DEBUG_START
this->disabled = true;
this->ClearContentCache();
this->placeholder_accessor.InvalidateAll();
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
char old_content_path[FS_MAX_PATH] = {0};
@@ -420,20 +382,15 @@ namespace sts::ncm {
}
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::SetPlaceHolderSize(PlaceHolderId placeholder_id, u64 size) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
R_TRY(this->placeholder_accessor.SetSize(placeholder_id, size));
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::ReadContentIdFile(OutBuffer<u8> buf, ContentId content_id, u64 offset) {
R_DEBUG_START
/* Offset is too large */
if (offset >> 0x3f != 0) {
return ResultNcmInvalidOffset;
@@ -446,11 +403,9 @@ namespace sts::ncm {
R_TRY(ReadFile(this->content_cache_file_handle, offset, buf.buffer, buf.num_elements));
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::GetRightsIdFromPlaceHolderId(Out<FsRightsId> out_rights_id, Out<u64> out_key_generation, PlaceHolderId placeholder_id) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
FsRightsId rights_id = {0};
@@ -466,11 +421,9 @@ namespace sts::ncm {
out_key_generation.SetValue(static_cast<u64>(key_generation));
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::GetRightsIdFromContentId(Out<FsRightsId> out_rights_id, Out<u64> out_key_generation, ContentId content_id) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
impl::RightsIdCache* rights_id_cache = impl::GetRightsIdCache();
@@ -527,11 +480,9 @@ namespace sts::ncm {
}
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::WriteContentForDebug(ContentId content_id, u64 offset, InBuffer<u8> data) {
R_DEBUG_START
/* Offset is too large */
if (offset >> 0x3f != 0) {
return ResultNcmInvalidOffset;
@@ -560,44 +511,34 @@ namespace sts::ncm {
R_TRY(WriteFile(f, offset, data.buffer, data.num_elements, FS_WRITEOPTION_FLUSH));
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::GetFreeSpaceSize(Out<u64> out_size) {
R_DEBUG_START
struct statvfs st = {0};
if (statvfs(this->root_path, &st) == -1) {
return fsdevGetLastResult();
}
D_LOG("free space: 0x%x\n", st.f_bfree);
out_size.SetValue(st.f_bfree);
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::GetTotalSpaceSize(Out<u64> out_size) {
R_DEBUG_START
struct statvfs st = {0};
if (statvfs(this->root_path, &st) == -1) {
return fsdevGetLastResult();
}
D_LOG("total space: 0x%x\n", st.f_blocks);
out_size.SetValue(st.f_blocks);
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::FlushPlaceHolder() {
R_DEBUG_START
this->placeholder_accessor.InvalidateAll();
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::GetSizeFromPlaceHolderId(Out<u64> out_size, PlaceHolderId placeholder_id) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
bool found_in_cache = false;
@@ -620,11 +561,9 @@ namespace sts::ncm {
out_size.SetValue(st.st_size);
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::RepairInvalidFileAttribute() {
R_DEBUG_START
char content_root_path[FS_MAX_PATH] = {0};
this->GetContentRootPath(content_root_path);
unsigned int dir_depth = this->GetContentDirectoryDepth();
@@ -653,11 +592,9 @@ namespace sts::ncm {
R_TRY(TraverseDirectory(placeholder_root_path, dir_depth, fix_file_attributes));
return ResultSuccess;
R_DEBUG_END
}
Result ContentStorageInterface::GetRightsIdFromPlaceHolderIdWithCache(Out<FsRightsId> out_rights_id, Out<u64> out_key_generation, PlaceHolderId placeholder_id, ContentId cache_content_id) {
R_DEBUG_START
R_TRY(this->EnsureEnabled());
impl::RightsIdCache* rights_id_cache = impl::GetRightsIdCache();
@@ -714,7 +651,6 @@ namespace sts::ncm {
}
return ResultSuccess;
R_DEBUG_END
}
}