mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-03 08:08:39 -04:00
libstrat: convert to experimental new (super-accurate) sf allocation semantics
This commit is contained in:
parent
8314d015f3
commit
f06de12bea
149 changed files with 2852 additions and 1746 deletions
|
@ -20,23 +20,25 @@ namespace ams::ncm {
|
|||
|
||||
namespace {
|
||||
|
||||
std::shared_ptr<IContentManager> g_content_manager;
|
||||
sf::SharedPointer<IContentManager> g_content_manager;
|
||||
|
||||
sf::UnmanagedServiceObject<IContentManager, RemoteContentManagerImpl> g_remote_manager_impl;
|
||||
|
||||
}
|
||||
|
||||
void Initialize() {
|
||||
AMS_ASSERT(g_content_manager == nullptr);
|
||||
R_ABORT_UNLESS(ncmInitialize());
|
||||
g_content_manager = sf::MakeShared<IContentManager, RemoteContentManagerImpl>();
|
||||
g_content_manager = g_remote_manager_impl.GetShared();
|
||||
}
|
||||
|
||||
void Finalize() {
|
||||
AMS_ASSERT(g_content_manager != nullptr);
|
||||
g_content_manager.reset();
|
||||
g_content_manager.Reset();
|
||||
ncmExit();
|
||||
}
|
||||
|
||||
void InitializeWithObject(std::shared_ptr<IContentManager> manager_object) {
|
||||
void InitializeWithObject(sf::SharedPointer<IContentManager> manager_object) {
|
||||
AMS_ASSERT(g_content_manager == nullptr);
|
||||
g_content_manager = manager_object;
|
||||
AMS_ASSERT(g_content_manager != nullptr);
|
||||
|
@ -60,18 +62,18 @@ namespace ams::ncm {
|
|||
}
|
||||
|
||||
Result OpenContentStorage(ContentStorage *out, StorageId storage_id) {
|
||||
sf::cmif::ServiceObjectHolder object_holder;
|
||||
R_TRY(g_content_manager->OpenContentStorage(std::addressof(object_holder), storage_id));
|
||||
sf::SharedPointer<IContentStorage> content_storage;
|
||||
R_TRY(g_content_manager->OpenContentStorage(std::addressof(content_storage), storage_id));
|
||||
|
||||
*out = ContentStorage(object_holder.GetServiceObject<IContentStorage>());
|
||||
*out = ContentStorage(std::move(content_storage));
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result OpenContentMetaDatabase(ContentMetaDatabase *out, StorageId storage_id) {
|
||||
sf::cmif::ServiceObjectHolder object_holder;
|
||||
R_TRY(g_content_manager->OpenContentMetaDatabase(std::addressof(object_holder), storage_id));
|
||||
sf::SharedPointer<IContentMetaDatabase> content_db;
|
||||
R_TRY(g_content_manager->OpenContentMetaDatabase(std::addressof(content_db), storage_id));
|
||||
|
||||
*out = ContentMetaDatabase(object_holder.GetServiceObject<IContentMetaDatabase>());
|
||||
*out = ContentMetaDatabase(std::move(content_db));
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
|
|
|
@ -465,7 +465,7 @@ namespace ams::ncm {
|
|||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result ContentManagerImpl::OpenContentStorage(sf::Out<std::shared_ptr<IContentStorage>> out, StorageId storage_id) {
|
||||
Result ContentManagerImpl::OpenContentStorage(sf::Out<sf::SharedPointer<IContentStorage>> out, StorageId storage_id) {
|
||||
std::scoped_lock lk(this->mutex);
|
||||
|
||||
/* Obtain the content storage root. */
|
||||
|
@ -482,11 +482,11 @@ namespace ams::ncm {
|
|||
}
|
||||
}
|
||||
|
||||
out.SetValue(std::shared_ptr<IContentStorage>(root->content_storage));
|
||||
*out = root->content_storage;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result ContentManagerImpl::OpenContentMetaDatabase(sf::Out<std::shared_ptr<IContentMetaDatabase>> out, StorageId storage_id) {
|
||||
Result ContentManagerImpl::OpenContentMetaDatabase(sf::Out<sf::SharedPointer<IContentMetaDatabase>> out, StorageId storage_id) {
|
||||
std::scoped_lock lk(this->mutex);
|
||||
|
||||
/* Obtain the content meta database root. */
|
||||
|
@ -503,7 +503,7 @@ namespace ams::ncm {
|
|||
}
|
||||
}
|
||||
|
||||
out.SetValue(std::shared_ptr<IContentMetaDatabase>(root->content_meta_database));
|
||||
*out = root->content_meta_database;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
|
@ -553,23 +553,23 @@ namespace ams::ncm {
|
|||
|
||||
if (storage_id == StorageId::GameCard) {
|
||||
/* Game card content storage is read only. */
|
||||
auto content_storage = sf::MakeShared<IContentStorage, ReadOnlyContentStorageImpl>();
|
||||
R_TRY(content_storage->GetImpl().Initialize(root->path, MakeFlatContentFilePath));
|
||||
auto content_storage = sf::CreateSharedObjectEmplaced<IContentStorage, ReadOnlyContentStorageImpl>();
|
||||
R_TRY(content_storage.GetImpl().Initialize(root->path, MakeFlatContentFilePath));
|
||||
root->content_storage = std::move(content_storage);
|
||||
} else {
|
||||
/* Create a content storage. */
|
||||
auto content_storage = sf::MakeShared<IContentStorage, ContentStorageImpl>();
|
||||
auto content_storage = sf::CreateSharedObjectEmplaced<IContentStorage, ContentStorageImpl>();
|
||||
|
||||
/* 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(this->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(this->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(this->rights_id_cache)));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -589,7 +589,7 @@ namespace ams::ncm {
|
|||
R_TRY(this->GetContentStorageRoot(std::addressof(root), storage_id));
|
||||
|
||||
/* Disable and unmount the content storage, if present. */
|
||||
if (root->content_storage) {
|
||||
if (root->content_storage != nullptr) {
|
||||
/* N doesn't bother checking the result of this */
|
||||
root->content_storage->DisableForcibly();
|
||||
root->content_storage = nullptr;
|
||||
|
@ -617,7 +617,7 @@ namespace ams::ncm {
|
|||
R_TRY(root->kvs->Initialize(root->max_content_metas, root->memory_resource));
|
||||
|
||||
/* Create an on memory content meta database for game cards. */
|
||||
root->content_meta_database = sf::MakeShared<IContentMetaDatabase, OnMemoryContentMetaDatabaseImpl>(std::addressof(*root->kvs));
|
||||
root->content_meta_database = sf::CreateSharedObjectEmplaced<IContentMetaDatabase, OnMemoryContentMetaDatabaseImpl>(std::addressof(*root->kvs));
|
||||
} else {
|
||||
/* Mount save data for this root. */
|
||||
R_TRY(fs::MountSystemSaveData(root->mount_name, root->info.space_id, root->info.id));
|
||||
|
@ -630,7 +630,7 @@ namespace ams::ncm {
|
|||
R_TRY(root->kvs->Load());
|
||||
|
||||
/* Create the content meta database. */
|
||||
root->content_meta_database = sf::MakeShared<IContentMetaDatabase, ContentMetaDatabaseImpl>(std::addressof(*root->kvs), root->mount_name);
|
||||
root->content_meta_database = sf::CreateSharedObjectEmplaced<IContentMetaDatabase, ContentMetaDatabaseImpl>(std::addressof(*root->kvs), root->mount_name);
|
||||
mount_guard.Cancel();
|
||||
}
|
||||
|
||||
|
@ -645,7 +645,7 @@ namespace ams::ncm {
|
|||
R_TRY(this->GetContentMetaDatabaseRoot(&root, storage_id));
|
||||
|
||||
/* Disable the content meta database, if present. */
|
||||
if (root->content_meta_database) {
|
||||
if (root->content_meta_database != nullptr) {
|
||||
/* N doesn't bother checking the result of this */
|
||||
root->content_meta_database->DisableForcibly();
|
||||
root->content_meta_database = nullptr;
|
||||
|
|
|
@ -49,12 +49,12 @@ namespace ams::ncm {
|
|||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result ContentMetaDatabaseImpl::Set(const ContentMetaKey &key, sf::InBuffer value) {
|
||||
Result ContentMetaDatabaseImpl::Set(const ContentMetaKey &key, const sf::InBuffer &value) {
|
||||
R_TRY(this->EnsureEnabled());
|
||||
return this->kvs->Set(key, value.GetPointer(), value.GetSize());
|
||||
}
|
||||
|
||||
Result ContentMetaDatabaseImpl::Get(sf::Out<u64> out_size, const ContentMetaKey &key, sf::OutBuffer out_value) {
|
||||
Result ContentMetaDatabaseImpl::Get(sf::Out<u64> out_size, const ContentMetaKey &key, const sf::OutBuffer &out_value) {
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
||||
/* Get the entry from our key-value store. */
|
||||
|
|
|
@ -28,8 +28,8 @@ namespace ams::ncm {
|
|||
Result GetContentIdImpl(ContentId *out, const ContentMetaKey &key, ContentType type, std::optional<u8> id_offset) const;
|
||||
public:
|
||||
/* Actual commands. */
|
||||
virtual Result Set(const ContentMetaKey &key, sf::InBuffer value) override;
|
||||
virtual Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, sf::OutBuffer out_value) override;
|
||||
virtual Result Set(const ContentMetaKey &key, const sf::InBuffer &value) override;
|
||||
virtual Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, const sf::OutBuffer &out_value) override;
|
||||
virtual Result Remove(const ContentMetaKey &key) override;
|
||||
virtual Result GetContentIdByType(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type) override;
|
||||
virtual Result ListContentInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentInfo> &out_info, const ContentMetaKey &key, s32 offset) override;
|
||||
|
|
|
@ -54,8 +54,8 @@ namespace ams::ncm {
|
|||
}
|
||||
public:
|
||||
/* Actual commands. */
|
||||
virtual Result Set(const ContentMetaKey &key, sf::InBuffer value) = 0;
|
||||
virtual Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, sf::OutBuffer out_value) = 0;
|
||||
virtual Result Set(const ContentMetaKey &key, const sf::InBuffer &value) = 0;
|
||||
virtual Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, const sf::OutBuffer &out_value) = 0;
|
||||
virtual Result Remove(const ContentMetaKey &key) = 0;
|
||||
virtual Result GetContentIdByType(sf::Out<ContentId> out_content_id, const ContentMetaKey &key, ContentType type) = 0;
|
||||
virtual Result ListContentInfo(sf::Out<s32> out_entries_written, const sf::OutArray<ContentInfo> &out_info, const ContentMetaKey &key, s32 offset) = 0;
|
||||
|
|
|
@ -292,7 +292,7 @@ namespace ams::ncm {
|
|||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result ContentStorageImpl::WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) {
|
||||
Result ContentStorageImpl::WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data) {
|
||||
/* Ensure offset is valid. */
|
||||
R_UNLESS(offset >= 0, ncm::ResultInvalidOffset());
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
@ -551,7 +551,7 @@ namespace ams::ncm {
|
|||
return this->placeholder_accessor.SetPlaceHolderFileSize(placeholder_id, size);
|
||||
}
|
||||
|
||||
Result ContentStorageImpl::ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) {
|
||||
Result ContentStorageImpl::ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) {
|
||||
/* Ensure offset is valid. */
|
||||
R_UNLESS(offset >= 0, ncm::ResultInvalidOffset());
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
@ -621,7 +621,7 @@ namespace ams::ncm {
|
|||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result ContentStorageImpl::WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) {
|
||||
Result ContentStorageImpl::WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) {
|
||||
/* Ensure offset is valid. */
|
||||
R_UNLESS(offset >= 0, ncm::ResultInvalidOffset());
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace ams::ncm {
|
|||
virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) override;
|
||||
virtual Result DeletePlaceHolder(PlaceHolderId placeholder_id) override;
|
||||
virtual Result HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) override;
|
||||
virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) override;
|
||||
virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data) override;
|
||||
virtual Result Register(PlaceHolderId placeholder_id, ContentId content_id) override;
|
||||
virtual Result Delete(ContentId content_id) override;
|
||||
virtual Result Has(sf::Out<bool> out, ContentId content_id) override;
|
||||
|
@ -59,12 +59,12 @@ namespace ams::ncm {
|
|||
virtual Result DisableForcibly() override;
|
||||
virtual Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) override;
|
||||
virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) override;
|
||||
virtual Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) override;
|
||||
virtual Result ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) override;
|
||||
virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) override;
|
||||
virtual Result GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id) override;
|
||||
virtual Result GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) override;
|
||||
virtual Result GetRightsIdFromContentId(sf::Out<ncm::RightsId> out_rights_id, ContentId content_id) override;
|
||||
virtual Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) override;
|
||||
virtual Result WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) override;
|
||||
virtual Result GetFreeSpaceSize(sf::Out<s64> out_size) override;
|
||||
virtual Result GetTotalSpaceSize(sf::Out<s64> out_size) override;
|
||||
virtual Result FlushPlaceHolder() override;
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace ams::ncm {
|
|||
virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) = 0;
|
||||
virtual Result DeletePlaceHolder(PlaceHolderId placeholder_id) = 0;
|
||||
virtual Result HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) = 0;
|
||||
virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) = 0;
|
||||
virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data) = 0;
|
||||
virtual Result Register(PlaceHolderId placeholder_id, ContentId content_id) = 0;
|
||||
virtual Result Delete(ContentId content_id) = 0;
|
||||
virtual Result Has(sf::Out<bool> out, ContentId content_id) = 0;
|
||||
|
@ -63,12 +63,12 @@ namespace ams::ncm {
|
|||
virtual Result DisableForcibly() = 0;
|
||||
virtual Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) = 0;
|
||||
virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) = 0;
|
||||
virtual Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) = 0;
|
||||
virtual Result ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) = 0;
|
||||
virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) = 0;
|
||||
virtual Result GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id) = 0;
|
||||
virtual Result GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) = 0;
|
||||
virtual Result GetRightsIdFromContentId(sf::Out<ncm::RightsId> out_rights_id, ContentId content_id) = 0;
|
||||
virtual Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) = 0;
|
||||
virtual Result WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) = 0;
|
||||
virtual Result GetFreeSpaceSize(sf::Out<s64> out_size) = 0;
|
||||
virtual Result GetTotalSpaceSize(sf::Out<s64> out_size) = 0;
|
||||
virtual Result FlushPlaceHolder() = 0;
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace ams::ncm {
|
|||
return ncm::ResultWriteToReadOnlyContentStorage();
|
||||
}
|
||||
|
||||
Result ReadOnlyContentStorageImpl::WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) {
|
||||
Result ReadOnlyContentStorageImpl::WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data) {
|
||||
return ncm::ResultWriteToReadOnlyContentStorage();
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ namespace ams::ncm {
|
|||
return ncm::ResultWriteToReadOnlyContentStorage();
|
||||
}
|
||||
|
||||
Result ReadOnlyContentStorageImpl::ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) {
|
||||
Result ReadOnlyContentStorageImpl::ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) {
|
||||
/* Ensure offset is valid. */
|
||||
R_UNLESS(offset >= 0, ncm::ResultInvalidOffset());
|
||||
R_TRY(this->EnsureEnabled());
|
||||
|
@ -231,7 +231,7 @@ namespace ams::ncm {
|
|||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result ReadOnlyContentStorageImpl::WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) {
|
||||
Result ReadOnlyContentStorageImpl::WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) {
|
||||
return ncm::ResultWriteToReadOnlyContentStorage();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace ams::ncm {
|
|||
virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) override;
|
||||
virtual Result DeletePlaceHolder(PlaceHolderId placeholder_id) override;
|
||||
virtual Result HasPlaceHolder(sf::Out<bool> out, PlaceHolderId placeholder_id) override;
|
||||
virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) override;
|
||||
virtual Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data) override;
|
||||
virtual Result Register(PlaceHolderId placeholder_id, ContentId content_id) override;
|
||||
virtual Result Delete(ContentId content_id) override;
|
||||
virtual Result Has(sf::Out<bool> out, ContentId content_id) override;
|
||||
|
@ -42,12 +42,12 @@ namespace ams::ncm {
|
|||
virtual Result DisableForcibly() override;
|
||||
virtual Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) override;
|
||||
virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) override;
|
||||
virtual Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) override;
|
||||
virtual Result ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) override;
|
||||
virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, PlaceHolderId placeholder_id) override;
|
||||
virtual Result GetRightsIdFromPlaceHolderId(sf::Out<ncm::RightsId> out_rights_id, PlaceHolderId placeholder_id) override;
|
||||
virtual Result GetRightsIdFromContentIdDeprecated(sf::Out<ams::fs::RightsId> out_rights_id, ContentId content_id) override;
|
||||
virtual Result GetRightsIdFromContentId(sf::Out<ncm::RightsId> out_rights_id, ContentId content_id) override;
|
||||
virtual Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) override;
|
||||
virtual Result WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) override;
|
||||
virtual Result GetFreeSpaceSize(sf::Out<s64> out_size) override;
|
||||
virtual Result GetTotalSpaceSize(sf::Out<s64> out_size) override;
|
||||
virtual Result FlushPlaceHolder() override;
|
||||
|
|
|
@ -20,7 +20,10 @@
|
|||
|
||||
namespace ams::ncm {
|
||||
|
||||
class RemoteContentManagerImpl final {
|
||||
class RemoteContentManagerImpl {
|
||||
private:
|
||||
/* TODO: sf::ProxyObjectAllocator */
|
||||
using ObjectFactory = sf::ObjectFactory<sf::StdAllocationPolicy<std::allocator>>;
|
||||
public:
|
||||
RemoteContentManagerImpl() { /* ... */ }
|
||||
|
||||
|
@ -42,19 +45,19 @@ namespace ams::ncm {
|
|||
return ::ncmVerifyContentMetaDatabase(static_cast<NcmStorageId>(storage_id));
|
||||
}
|
||||
|
||||
Result OpenContentStorage(sf::Out<std::shared_ptr<IContentStorage>> out, StorageId storage_id) {
|
||||
Result OpenContentStorage(sf::Out<sf::SharedPointer<IContentStorage>> out, StorageId storage_id) {
|
||||
NcmContentStorage cs;
|
||||
R_TRY(::ncmOpenContentStorage(std::addressof(cs), static_cast<NcmStorageId>(storage_id)));
|
||||
|
||||
out.SetValue(sf::MakeShared<IContentStorage, RemoteContentStorageImpl>(cs));
|
||||
out.SetValue(ObjectFactory::CreateSharedEmplaced<IContentStorage, RemoteContentStorageImpl>(cs));
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result OpenContentMetaDatabase(sf::Out<std::shared_ptr<IContentMetaDatabase>> out, StorageId storage_id) {
|
||||
Result OpenContentMetaDatabase(sf::Out<sf::SharedPointer<IContentMetaDatabase>> out, StorageId storage_id) {
|
||||
NcmContentMetaDatabase db;
|
||||
R_TRY(::ncmOpenContentMetaDatabase(std::addressof(db), static_cast<NcmStorageId>(storage_id)));
|
||||
|
||||
out.SetValue(sf::MakeShared<IContentMetaDatabase, RemoteContentMetaDatabaseImpl>(db));
|
||||
out.SetValue(ObjectFactory::CreateSharedEmplaced<IContentMetaDatabase, RemoteContentMetaDatabaseImpl>(db));
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
namespace ams::ncm {
|
||||
|
||||
class RemoteContentMetaDatabaseImpl final {
|
||||
class RemoteContentMetaDatabaseImpl {
|
||||
private:
|
||||
::NcmContentMetaDatabase srv;
|
||||
public:
|
||||
|
@ -71,11 +71,11 @@ namespace ams::ncm {
|
|||
return reinterpret_cast<const ::NcmContentId *>(std::addressof(c));
|
||||
}
|
||||
public:
|
||||
Result Set(const ContentMetaKey &key, sf::InBuffer value) {
|
||||
Result Set(const ContentMetaKey &key, const sf::InBuffer &value) {
|
||||
return ncmContentMetaDatabaseSet(std::addressof(this->srv), Convert(key), value.GetPointer(), value.GetSize());
|
||||
}
|
||||
|
||||
Result Get(sf::Out<u64> out_size, const ContentMetaKey &key, sf::OutBuffer out_value) {
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
namespace ams::ncm {
|
||||
|
||||
class RemoteContentStorageImpl final {
|
||||
class RemoteContentStorageImpl {
|
||||
private:
|
||||
::NcmContentStorage srv;
|
||||
public:
|
||||
|
@ -63,7 +63,7 @@ namespace ams::ncm {
|
|||
return ncmContentStorageHasPlaceHolder(std::addressof(this->srv), out.GetPointer(), Convert(placeholder_id));
|
||||
}
|
||||
|
||||
Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, sf::InBuffer data) {
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ namespace ams::ncm {
|
|||
return ncmContentStorageSetPlaceHolderSize(std::addressof(this->srv), Convert(placeholder_id), size);
|
||||
}
|
||||
|
||||
Result ReadContentIdFile(sf::OutBuffer buf, ContentId content_id, s64 offset) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ namespace ams::ncm {
|
|||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result WriteContentForDebug(ContentId content_id, s64 offset, sf::InBuffer data) {
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue