/* * Copyright (c) Atmosphère-NX * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "ncm_host_content_storage_impl.hpp" namespace ams::ncm { Result HostContentStorageImpl::GeneratePlaceHolderId(sf::Out out) { AMS_UNUSED(out); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) { AMS_UNUSED(placeholder_id, content_id, size); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::DeletePlaceHolder(PlaceHolderId placeholder_id) { AMS_UNUSED(placeholder_id); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::HasPlaceHolder(sf::Out out, PlaceHolderId placeholder_id) { AMS_UNUSED(out, placeholder_id); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data) { AMS_UNUSED(placeholder_id, offset, data); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::Register(PlaceHolderId placeholder_id, ContentId content_id) { AMS_UNUSED(placeholder_id, content_id); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::Delete(ContentId content_id) { AMS_UNUSED(content_id); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::Has(sf::Out out, ContentId content_id) { R_TRY(this->EnsureEnabled()); /* Attempt to locate the content. */ Path path; 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); R_SUCCEED(); } } R_END_TRY_CATCH; out.SetValue(true); R_SUCCEED(); } Result HostContentStorageImpl::GetPath(sf::Out out, ContentId content_id) { R_TRY(this->EnsureEnabled()); R_RETURN(m_registered_content->GetPath(out.GetPointer(), content_id)); } Result HostContentStorageImpl::GetPlaceHolderPath(sf::Out out, PlaceHolderId placeholder_id) { AMS_UNUSED(out, placeholder_id); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::CleanupAllPlaceHolder() { R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::ListPlaceHolder(sf::Out out_count, const sf::OutArray &out_buf) { AMS_UNUSED(out_count, out_buf); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::GetContentCount(sf::Out out_count) { AMS_UNUSED(out_count); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::ListContentId(sf::Out out_count, const sf::OutArray &out_buf, s32 offset) { AMS_UNUSED(out_count, out_buf, offset); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::GetSizeFromContentId(sf::Out out_size, ContentId content_id) { AMS_UNUSED(out_size, content_id); R_THROW(ncm::ResultInvalidOperation()); } Result HostContentStorageImpl::DisableForcibly() { m_disabled = true; R_SUCCEED(); } Result HostContentStorageImpl::RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) { AMS_UNUSED(placeholder_id, old_content_id, new_content_id); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) { AMS_UNUSED(placeholder_id, size); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) { AMS_UNUSED(buf, content_id, offset); R_THROW(ncm::ResultInvalidOperation()); } Result HostContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) { AMS_UNUSED(out_rights_id, placeholder_id); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id) { AMS_UNUSED(out_rights_id, placeholder_id); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) { /* Obtain the regular rights id for the content id. */ ncm::RightsId rights_id; R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id)); /* Output the fs rights id. */ out_rights_id.SetValue(rights_id.id); R_SUCCEED(); } Result HostContentStorageImpl::GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id) { R_TRY(this->EnsureEnabled()); /* Get the content path. */ Path path; R_TRY(m_registered_content->GetPath(std::addressof(path), content_id)); /* Acquire the rights id for the content. */ RightsId rights_id; R_TRY_CATCH(GetRightsId(std::addressof(rights_id), path)) { /* The content is absent, output a blank rights id. */ R_CATCH(fs::ResultTargetNotFound) { out_rights_id.SetValue({}); R_SUCCEED(); } } R_END_TRY_CATCH; /* Output the rights id. */ out_rights_id.SetValue(rights_id); R_SUCCEED(); } Result HostContentStorageImpl::WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) { AMS_UNUSED(content_id, offset, data); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::GetFreeSpaceSize(sf::Out out_size) { out_size.SetValue(0); R_SUCCEED(); } Result HostContentStorageImpl::GetTotalSpaceSize(sf::Out out_size) { out_size.SetValue(0); R_SUCCEED(); } Result HostContentStorageImpl::FlushPlaceHolder() { R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::GetSizeFromPlaceHolderId(sf::Out out, PlaceHolderId placeholder_id) { AMS_UNUSED(out, placeholder_id); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::RepairInvalidFileAttribute() { R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { AMS_UNUSED(out_rights_id, placeholder_id, cache_content_id); R_THROW(ncm::ResultNotSupported()); } Result HostContentStorageImpl::RegisterPath(const ContentId &content_id, const Path &path) { AMS_ABORT_UNLESS(spl::IsDevelopment()); R_RETURN(m_registered_content->RegisterPath(content_id, path)); } Result HostContentStorageImpl::ClearRegisteredPath() { AMS_ABORT_UNLESS(spl::IsDevelopment()); m_registered_content->ClearPaths(); R_SUCCEED(); } }