diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp index 0f0c8f31b..bba72ec02 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp @@ -47,7 +47,7 @@ namespace ams::ncm { GetContentIdByTypeAndIdOffset = 20, }; protected: - ams::kvdb::MemoryKeyValueStore* kvs; + ams::kvdb::MemoryKeyValueStore *kvs; char mount_name[16]; bool disabled; protected: @@ -56,13 +56,13 @@ namespace ams::ncm { return ResultSuccess(); } public: - IContentMetaDatabase(ams::kvdb::MemoryKeyValueStore* kvs) : + IContentMetaDatabase(ams::kvdb::MemoryKeyValueStore *kvs) : kvs(kvs), disabled(false) { /* ... */ } - IContentMetaDatabase(ams::kvdb::MemoryKeyValueStore* kvs, const char* mount_name) : + IContentMetaDatabase(ams::kvdb::MemoryKeyValueStore *kvs, const char *mount_name) : IContentMetaDatabase(kvs) { std::strcpy(this->mount_name, mount_name); @@ -92,8 +92,8 @@ namespace ams::ncm { virtual Result GetContentIdByTypeAndIdOffset(sf::Out out_content_id, ContentMetaKey key, ContentType type, u8 id_offset) = 0; /* APIs. */ - virtual Result GetLatestProgram(ContentId* out_content_id, ProgramId program_id) = 0; - virtual Result GetLatestData(ContentId* out_content_id, ProgramId program_id) = 0; + virtual Result GetLatestProgram(ContentId *out_content_id, ProgramId program_id) = 0; + virtual Result GetLatestData(ContentId *out_content_id, ProgramId program_id) = 0; public: DEFINE_SERVICE_DISPATCH_TABLE { MAKE_SERVICE_COMMAND_META(Set), diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_types.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_types.hpp index e349a3e56..c47a037d3 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_types.hpp @@ -114,8 +114,8 @@ namespace ams::ncm { static_assert(sizeof(ContentInfo) == 0x18, "ContentInfo definition!"); - using MakeContentPathFunc = void (*)(char* out, ContentId content_id, const char* root); - using MakePlaceHolderPathFunc = void (*)(char* out, PlaceHolderId placeholder_id, const char* root); + using MakeContentPathFunc = void (*)(char *out, ContentId content_id, const char *root); + using MakePlaceHolderPathFunc = void (*)(char *out, PlaceHolderId placeholder_id, const char *root); /* Storage IDs. */ enum class StorageId : u8 { diff --git a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp index 56e4a0011..9398ff327 100644 --- a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp @@ -31,7 +31,7 @@ namespace ams::lr { } /* Helper function. */ - void ContentLocationResolverImpl::GetContentStoragePath(Path* out, ncm::ContentId content_id) { + void ContentLocationResolverImpl::GetContentStoragePath(Path *out, ncm::ContentId content_id) { R_ABORT_UNLESS(this->content_storage->GetPath(out, content_id)); } diff --git a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp index 42dc9686d..e25af0050 100644 --- a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp @@ -32,7 +32,7 @@ namespace ams::lr { ~ContentLocationResolverImpl(); private: /* Helper functions. */ - void GetContentStoragePath(Path* out, ncm::ContentId content_id); + void GetContentStoragePath(Path *out, ncm::ContentId content_id); public: /* Actual commands. */ virtual Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) override; diff --git a/libraries/libstratosphere/source/lr/lr_location_redirector.cpp b/libraries/libstratosphere/source/lr/lr_location_redirector.cpp index a1cc0bd67..fff5b83d3 100644 --- a/libraries/libstratosphere/source/lr/lr_location_redirector.cpp +++ b/libraries/libstratosphere/source/lr/lr_location_redirector.cpp @@ -109,7 +109,7 @@ namespace ams::lr { } } - void LocationRedirector::ClearRedirectionsExcludingOwners(const ncm::ProgramId* excluding_ids, size_t num_ids) { + void LocationRedirector::ClearRedirectionsExcludingOwners(const ncm::ProgramId *excluding_ids, size_t num_ids) { for (auto it = this->redirection_list.begin(); it != this->redirection_list.end();) { /* Skip removal if the redirection has an excluded owner program id. */ if (this->IsExcluded(it->GetOwnerProgramId(), excluding_ids, num_ids)) { diff --git a/libraries/libstratosphere/source/lr/lr_location_redirector.hpp b/libraries/libstratosphere/source/lr/lr_location_redirector.hpp index 16cbecdb0..766ce10c6 100644 --- a/libraries/libstratosphere/source/lr/lr_location_redirector.hpp +++ b/libraries/libstratosphere/source/lr/lr_location_redirector.hpp @@ -44,9 +44,9 @@ namespace ams::lr { void SetRedirectionFlags(ncm::ProgramId program_id, u32 flags); void EraseRedirection(ncm::ProgramId program_id); void ClearRedirections(u32 flags = RedirectionFlags_None); - void ClearRedirectionsExcludingOwners(const ncm::ProgramId* excluding_ids, size_t num_ids); + void ClearRedirectionsExcludingOwners(const ncm::ProgramId *excluding_ids, size_t num_ids); private: - inline bool IsExcluded(const ncm::ProgramId id, const ncm::ProgramId* excluding_ids, size_t num_ids) const { + inline bool IsExcluded(const ncm::ProgramId id, const ncm::ProgramId *excluding_ids, size_t num_ids) const { for (size_t i = 0; i < num_ids; i++) { if (id == excluding_ids[i]) { return true; diff --git a/libraries/libstratosphere/source/lr/lr_location_resolver_impl_base.hpp b/libraries/libstratosphere/source/lr/lr_location_resolver_impl_base.hpp index 2f87824bf..d8931d041 100644 --- a/libraries/libstratosphere/source/lr/lr_location_resolver_impl_base.hpp +++ b/libraries/libstratosphere/source/lr/lr_location_resolver_impl_base.hpp @@ -42,7 +42,7 @@ namespace ams::lr { this->legal_info_redirector.ClearRedirections(flags); } - void ClearRedirections(const ncm::ProgramId* excluding_ids, size_t num_ids) { + void ClearRedirections(const ncm::ProgramId *excluding_ids, size_t num_ids) { this->program_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); this->debug_program_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); this->app_control_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); diff --git a/libraries/libstratosphere/source/lr/lr_registered_data.hpp b/libraries/libstratosphere/source/lr/lr_registered_data.hpp index 0871a4ffe..109baa5f2 100644 --- a/libraries/libstratosphere/source/lr/lr_registered_data.hpp +++ b/libraries/libstratosphere/source/lr/lr_registered_data.hpp @@ -34,7 +34,7 @@ namespace ams::lr { Entry entries[NumEntries]; size_t capacity; private: - inline bool IsExcluded(const ncm::ProgramId id, const ncm::ProgramId* excluding_ids, size_t num_ids) const { + inline bool IsExcluded(const ncm::ProgramId id, const ncm::ProgramId *excluding_ids, size_t num_ids) const { /* Try to find program id in exclusions. */ for (size_t i = 0; i < num_ids; i++) { if (id == excluding_ids[i]) { @@ -120,7 +120,7 @@ namespace ams::lr { } } - void ClearExcluding(const ncm::ProgramId* ids, size_t num_ids) { + void ClearExcluding(const ncm::ProgramId *ids, size_t num_ids) { /* Invalidate all entries unless excluded. */ for (size_t i = 0; i < this->GetCapacity(); i++) { Entry& entry = this->entries[i]; diff --git a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.cpp index 397fcfb3d..ce4755e03 100644 --- a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.cpp @@ -57,7 +57,7 @@ namespace ams::lr { this->program_redirector.ClearRedirections(flags); } - Result RegisteredLocationResolverImpl::RefreshImpl(const ncm::ProgramId* excluding_ids, size_t num_ids) { + Result RegisteredLocationResolverImpl::RefreshImpl(const ncm::ProgramId *excluding_ids, size_t num_ids) { /* On < 9.0.0, exclusion lists were not supported yet, so simply clear and return. */ if (hos::GetVersion() < hos::Version_900) { this->ClearRedirections(); diff --git a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp index a51718e70..a5d9837ee 100644 --- a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp @@ -43,7 +43,7 @@ namespace ams::lr { private: /* Helper functions. */ void ClearRedirections(u32 flags = RedirectionFlags_None); - Result RefreshImpl(const ncm::ProgramId* excluding_ids, size_t num_ids); + Result RefreshImpl(const ncm::ProgramId *excluding_ids, size_t num_ids); public: RegisteredLocationResolverImpl() : registered_program_locations(GetMaxRegisteredLocations()), registered_html_docs_locations(GetMaxRegisteredLocations()) { /* ... */ } ~RegisteredLocationResolverImpl(); diff --git a/stratosphere/ncm/source/impl/ncm_content_manager.cpp b/stratosphere/ncm/source/impl/ncm_content_manager.cpp index 9421b9a21..7161cf65d 100644 --- a/stratosphere/ncm/source/impl/ncm_content_manager.cpp +++ b/stratosphere/ncm/source/impl/ncm_content_manager.cpp @@ -167,7 +167,7 @@ namespace ams::ncm::impl { Result FindContentStorageRoot(ContentStorageRoot **out, StorageId storage_id) { for (size_t i = 0; i < MaxContentStorageEntries; i++) { - ContentStorageRoot* root = &g_content_storage_roots[i]; + ContentStorageRoot *root = &g_content_storage_roots[i]; if (root->storage_id == storage_id) { *out = root; @@ -185,7 +185,7 @@ namespace ams::ncm::impl { Result FindContentMetaDatabaseEntry(ContentMetaDatabaseEntry **out, StorageId storage_id) { for (size_t i = 0; i < MaxContentMetaDatabaseEntries; i++) { - ContentMetaDatabaseEntry* entry = &g_content_meta_entries[i]; + ContentMetaDatabaseEntry *entry = &g_content_meta_entries[i]; if (entry->storage_id == storage_id) { *out = entry; @@ -255,12 +255,12 @@ namespace ams::ncm::impl { R_UNLESS(!g_initialized, ResultSuccess()); for (size_t i = 0; i < MaxContentStorageEntries; i++) { - ContentStorageRoot* entry = &g_content_storage_roots[i]; + ContentStorageRoot *entry = &g_content_storage_roots[i]; entry->storage_id = StorageId::None; } for (size_t i = 0; i < MaxContentMetaDatabaseEntries; i++) { - ContentMetaDatabaseEntry* entry = &g_content_meta_entries[i]; + ContentMetaDatabaseEntry *entry = &g_content_meta_entries[i]; entry->storage_id = StorageId::None; } @@ -314,23 +314,23 @@ namespace ams::ncm::impl { std::scoped_lock lk(g_mutex); for (size_t i = 0; i < MaxContentStorageEntries; i++) { - ContentStorageRoot* entry = &g_content_storage_roots[i]; + ContentStorageRoot *entry = &g_content_storage_roots[i]; InactivateContentStorage(entry->storage_id); } for (size_t i = 0; i < MaxContentMetaDatabaseEntries; i++) { - ContentMetaDatabaseEntry* entry = &g_content_meta_entries[i]; + ContentMetaDatabaseEntry *entry = &g_content_meta_entries[i]; InactivateContentMetaDatabase(entry->storage_id); } } for (size_t i = 0; i < MaxContentMetaDatabaseEntries; i++) { - ContentMetaDatabaseEntry* entry = &g_content_meta_entries[i]; + ContentMetaDatabaseEntry *entry = &g_content_meta_entries[i]; entry->kvs.reset(); } for (size_t i = 0; i < MaxContentStorageEntries; i++) { - ContentStorageRoot* entry = &g_content_storage_roots[i]; + ContentStorageRoot *entry = &g_content_storage_roots[i]; entry->content_storage = nullptr; } } @@ -338,7 +338,7 @@ namespace ams::ncm::impl { Result CreateContentStorage(StorageId storage_id) { std::scoped_lock lk(g_mutex); - ContentStorageRoot* root; + ContentStorageRoot *root; R_TRY(GetUniqueContentStorageRoot(std::addressof(root), storage_id)); R_TRY(fs::MountContentStorage(root->mount_point, root->content_storage_id)); @@ -353,7 +353,7 @@ namespace ams::ncm::impl { Result VerifyContentStorage(StorageId storage_id) { std::scoped_lock lk(g_mutex); - ContentStorageRoot* root; + ContentStorageRoot *root; R_TRY(GetUniqueContentStorageRoot(std::addressof(root), storage_id)); char mount_root[0x80] = {}; @@ -368,10 +368,10 @@ namespace ams::ncm::impl { return ResultSuccess(); } - Result OpenContentStorage(std::shared_ptr* out, StorageId storage_id) { + Result OpenContentStorage(std::shared_ptr *out, StorageId storage_id) { std::scoped_lock lk(g_mutex); - ContentStorageRoot* root; + ContentStorageRoot *root; R_TRY(GetUniqueContentStorageRoot(std::addressof(root), storage_id)); auto content_storage = root->content_storage; @@ -394,7 +394,7 @@ namespace ams::ncm::impl { std::scoped_lock lk(g_mutex); R_UNLESS(storage_id != StorageId::None, ncm::ResultUnknownStorage()); - ContentStorageRoot* root; + ContentStorageRoot *root; R_TRY(FindContentStorageRoot(std::addressof(root), storage_id)); if (root->content_storage) { @@ -410,7 +410,7 @@ namespace ams::ncm::impl { Result ActivateContentStorage(StorageId storage_id) { std::scoped_lock lk(g_mutex); - ContentStorageRoot* root; + ContentStorageRoot *root; R_TRY(GetUniqueContentStorageRoot(std::addressof(root), storage_id)); /* Already activated. */ @@ -460,7 +460,7 @@ namespace ams::ncm::impl { Result InactivateContentStorage(StorageId storage_id) { std::scoped_lock lk(g_mutex); - ContentStorageRoot* root; + ContentStorageRoot *root; R_TRY(GetUniqueContentStorageRoot(std::addressof(root), storage_id)); /* Already inactivated. */ @@ -476,7 +476,7 @@ namespace ams::ncm::impl { std::scoped_lock lk(g_mutex); R_UNLESS(storage_id != StorageId::GameCard, ncm::ResultUnknownStorage()); - ContentMetaDatabaseEntry* entry; + ContentMetaDatabaseEntry *entry; R_TRY(GetUniqueContentMetaDatabaseEntry(&entry, storage_id)); /* N doesn't bother checking the result of this. */ @@ -495,7 +495,7 @@ namespace ams::ncm::impl { std::scoped_lock lk(g_mutex); R_UNLESS(storage_id != StorageId::GameCard, ResultSuccess()); - ContentMetaDatabaseEntry* entry; + ContentMetaDatabaseEntry *entry; R_TRY(GetUniqueContentMetaDatabaseEntry(&entry, storage_id)); auto mount_guard = SCOPE_GUARD { fs::Unmount(entry->mount_point); }; @@ -512,10 +512,10 @@ namespace ams::ncm::impl { return ResultSuccess(); } - Result OpenContentMetaDatabase(std::shared_ptr* out, StorageId storage_id) { + Result OpenContentMetaDatabase(std::shared_ptr *out, StorageId storage_id) { std::scoped_lock lk(g_mutex); - ContentMetaDatabaseEntry* entry; + ContentMetaDatabaseEntry *entry; R_TRY(GetUniqueContentMetaDatabaseEntry(&entry, storage_id)); auto content_meta_db = entry->content_meta_database; @@ -538,7 +538,7 @@ namespace ams::ncm::impl { std::scoped_lock lk(g_mutex); R_UNLESS(storage_id != StorageId::None, ncm::ResultUnknownStorage()); - ContentMetaDatabaseEntry* entry; + ContentMetaDatabaseEntry *entry; R_TRY(FindContentMetaDatabaseEntry(&entry, storage_id)); auto content_meta_db = entry->content_meta_database; @@ -561,7 +561,7 @@ namespace ams::ncm::impl { Result CleanupContentMetaDatabase(StorageId storage_id) { std::scoped_lock lk(g_mutex); - ContentMetaDatabaseEntry* entry; + ContentMetaDatabaseEntry *entry; R_TRY(GetUniqueContentMetaDatabaseEntry(&entry, storage_id)); R_TRY(fsDeleteSaveDataFileSystemBySaveDataSpaceId(entry->save_meta.space_id, entry->save_meta.id)); @@ -571,7 +571,7 @@ namespace ams::ncm::impl { Result ActivateContentMetaDatabase(StorageId storage_id) { std::scoped_lock lk(g_mutex); - ContentMetaDatabaseEntry* entry; + ContentMetaDatabaseEntry *entry; R_TRY(GetUniqueContentMetaDatabaseEntry(&entry, storage_id)); /* Already activated. */ @@ -599,7 +599,7 @@ namespace ams::ncm::impl { Result InactivateContentMetaDatabase(StorageId storage_id) { std::scoped_lock lk(g_mutex); - ContentMetaDatabaseEntry* entry; + ContentMetaDatabaseEntry *entry; R_TRY(GetUniqueContentMetaDatabaseEntry(&entry, storage_id)); /* Already inactivated. */ diff --git a/stratosphere/ncm/source/impl/ncm_content_manager.hpp b/stratosphere/ncm/source/impl/ncm_content_manager.hpp index 844a0d58f..7f68dda18 100644 --- a/stratosphere/ncm/source/impl/ncm_content_manager.hpp +++ b/stratosphere/ncm/source/impl/ncm_content_manager.hpp @@ -27,7 +27,7 @@ namespace ams::ncm::impl { /* Content Storage Management. */ Result CreateContentStorage(StorageId storage_id); Result VerifyContentStorage(StorageId storage_id); - Result OpenContentStorage(std::shared_ptr* out, StorageId storage_id); + Result OpenContentStorage(std::shared_ptr *out, StorageId storage_id); Result CloseContentStorageForcibly(StorageId storage_id); Result ActivateContentStorage(StorageId storage_id); Result InactivateContentStorage(StorageId storage_id); @@ -35,7 +35,7 @@ namespace ams::ncm::impl { /* Content Meta Database Management. */ Result CreateContentMetaDatabase(StorageId storage_id); Result VerifyContentMetaDatabase(StorageId storage_id); - Result OpenContentMetaDatabase(std::shared_ptr* out, StorageId storage_id); + Result OpenContentMetaDatabase(std::shared_ptr *out, StorageId storage_id); Result CloseContentMetaDatabaseForcibly(StorageId storage_id); Result CleanupContentMetaDatabase(StorageId storage_id); Result ActivateContentMetaDatabase(StorageId storage_id); diff --git a/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp b/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp index 6642f20cb..659bc88d4 100644 --- a/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp +++ b/stratosphere/ncm/source/impl/ncm_placeholder_accessor.cpp @@ -27,7 +27,7 @@ namespace ams::ncm::impl { char placeholder_path[FS_MAX_PATH] = {0}; this->MakePath(placeholder_path, placeholder_id); - FILE* f = nullptr; + FILE *f = nullptr; R_TRY(fs::OpenFile(&f, placeholder_path, FsOpenMode_Write)); *out_handle = f; @@ -57,7 +57,7 @@ namespace ams::ncm::impl { PlaceHolderAccessor::CacheEntry *PlaceHolderAccessor::GetFreeEntry() { /* Try to find an already free entry. */ - CacheEntry* entry = this->FindInCache(InvalidPlaceHolderId); + CacheEntry *entry = this->FindInCache(InvalidPlaceHolderId); if (entry) { return entry; @@ -76,7 +76,7 @@ namespace ams::ncm::impl { } } - void PlaceHolderAccessor::StoreToCache(FILE* handle, PlaceHolderId placeholder_id) { + void PlaceHolderAccessor::StoreToCache(FILE *handle, PlaceHolderId placeholder_id) { std::scoped_lock lk(this->cache_mutex); CacheEntry *entry = this->GetFreeEntry(); entry->id = placeholder_id; @@ -95,7 +95,7 @@ namespace ams::ncm::impl { } } - void PlaceHolderAccessor::Initialize(char* root, MakePlaceHolderPathFunc path_func, bool delay_flush) { + void PlaceHolderAccessor::Initialize(char *root, MakePlaceHolderPathFunc path_func, bool delay_flush) { this->root_path = root; this->make_placeholder_path_func = path_func; this->delay_flush = delay_flush; @@ -111,9 +111,9 @@ namespace ams::ncm::impl { AMS_ABORT(); } - void PlaceHolderAccessor::GetPath(char* placeholder_path_out, PlaceHolderId placeholder_id) { + void PlaceHolderAccessor::GetPath(char *placeholder_path_out, PlaceHolderId placeholder_id) { std::scoped_lock lock(this->cache_mutex); - CacheEntry* entry = this->FindInCache(placeholder_id); + CacheEntry *entry = this->FindInCache(placeholder_id); this->Invalidate(entry); this->MakePath(placeholder_path_out, placeholder_id); } @@ -145,8 +145,8 @@ namespace ams::ncm::impl { return ResultSuccess(); } - Result PlaceHolderAccessor::Write(PlaceHolderId placeholder_id, size_t offset, const void* buffer, size_t size) { - FILE* f = nullptr; + Result PlaceHolderAccessor::Write(PlaceHolderId placeholder_id, size_t offset, const void *buffer, size_t size) { + FILE *f = nullptr; R_TRY_CATCH(this->Open(&f, placeholder_id)) { R_CONVERT(ams::fs::ResultPathNotFound, ncm::ResultPlaceHolderNotFound()) @@ -172,8 +172,8 @@ namespace ams::ncm::impl { return ResultSuccess(); } - Result PlaceHolderAccessor::GetSize(bool* found_in_cache, size_t* out_size, PlaceHolderId placeholder_id) { - FILE* f = NULL; + Result PlaceHolderAccessor::GetSize(bool *found_in_cache, size_t *out_size, PlaceHolderId placeholder_id) { + FILE *f = NULL; /* Set the scope for the scoped_lock. */ { @@ -184,7 +184,7 @@ namespace ams::ncm::impl { return ResultSuccess(); } - CacheEntry* cache_entry = this->FindInCache(placeholder_id); + CacheEntry *cache_entry = this->FindInCache(placeholder_id); if (cache_entry == nullptr) { *found_in_cache = false; diff --git a/stratosphere/ncm/source/impl/ncm_placeholder_accessor.hpp b/stratosphere/ncm/source/impl/ncm_placeholder_accessor.hpp index bc81fc12c..0f5c5ecdb 100644 --- a/stratosphere/ncm/source/impl/ncm_placeholder_accessor.hpp +++ b/stratosphere/ncm/source/impl/ncm_placeholder_accessor.hpp @@ -27,14 +27,14 @@ namespace ams::ncm::impl { class CacheEntry { public: PlaceHolderId id; - FILE* handle; + FILE *handle; u64 counter; }; private: static constexpr size_t MaxCaches = 0x2; std::array caches; - char* root_path; + char *root_path; u64 cur_counter; os::Mutex cache_mutex; MakePlaceHolderPathFunc make_placeholder_path_func; @@ -44,7 +44,7 @@ namespace ams::ncm::impl { CacheEntry *FindInCache(PlaceHolderId placeholder_id); bool LoadFromCache(FILE** out_handle, PlaceHolderId placeholder_id); CacheEntry *GetFreeEntry(); - void StoreToCache(FILE* handle, PlaceHolderId placeholder_id); + void StoreToCache(FILE *handle, PlaceHolderId placeholder_id); void Invalidate(CacheEntry *entry); public: PlaceHolderAccessor() : cur_counter(0), delay_flush(false) { @@ -53,24 +53,24 @@ namespace ams::ncm::impl { } } - inline void MakeRootPath(char* out_placeholder_root) { + inline void MakeRootPath(char *out_placeholder_root) { path::GetPlaceHolderRootPath(out_placeholder_root, this->root_path); } - inline void MakePath(char* out_placeholder_path, PlaceHolderId placeholder_id) { + inline void MakePath(char *out_placeholder_path, PlaceHolderId placeholder_id) { char placeholder_root_path[FS_MAX_PATH] = {0}; this->MakeRootPath(placeholder_root_path); this->make_placeholder_path_func(out_placeholder_path, placeholder_id, placeholder_root_path); } - void Initialize(char* root, MakePlaceHolderPathFunc path_func, bool delay_flush); + void Initialize(char *root, MakePlaceHolderPathFunc path_func, bool delay_flush); unsigned int GetDirectoryDepth(); - void GetPath(char* out_placeholder_path, PlaceHolderId placeholder_id); + void GetPath(char *out_placeholder_path, PlaceHolderId placeholder_id); Result Create(PlaceHolderId placeholder_id, size_t size); Result Delete(PlaceHolderId placeholder_id); - Result Write(PlaceHolderId placeholder_id, size_t offset, const void* buffer, size_t size); + Result Write(PlaceHolderId placeholder_id, size_t offset, const void *buffer, size_t size); Result SetSize(PlaceHolderId placeholder_id, size_t size); - Result GetSize(bool* found_in_cache, size_t* out_size, PlaceHolderId placeholder_id); + Result GetSize(bool *found_in_cache, size_t *out_size, PlaceHolderId placeholder_id); Result EnsureRecursively(PlaceHolderId placeholder_id); void InvalidateAll(); }; diff --git a/stratosphere/ncm/source/ncm_content_meta_database.cpp b/stratosphere/ncm/source/ncm_content_meta_database.cpp index 75b53bdac..315949977 100644 --- a/stratosphere/ncm/source/ncm_content_meta_database.cpp +++ b/stratosphere/ncm/source/ncm_content_meta_database.cpp @@ -54,20 +54,20 @@ namespace ams::ncm { u32 extended_data_size; }; - inline const ContentMetaHeader* GetValueHeader(const void* value) { + inline const ContentMetaHeader *GetValueHeader(const void *value) { return reinterpret_cast(value); } template - inline const ExtendedHeaderType* GetValueExtendedHeader(const void* value) { + inline const ExtendedHeaderType *GetValueExtendedHeader(const void *value) { return reinterpret_cast(reinterpret_cast(value) + sizeof(ContentMetaHeader)); } - inline const ContentInfo* GetValueContentInfos(const void* value) { + inline const ContentInfo *GetValueContentInfos(const void *value) { return reinterpret_cast(reinterpret_cast(value) + sizeof(ContentMetaHeader) + GetValueHeader(value)->extended_header_size); } - inline const ContentMetaInfo* GetValueContentMetaInfos(const void* value) { + inline const ContentMetaInfo *GetValueContentMetaInfos(const void *value) { auto header = GetValueHeader(value); return reinterpret_cast(reinterpret_cast(GetValueContentInfos(value)) + sizeof(ContentInfo) * header->content_count); } @@ -88,7 +88,7 @@ namespace ams::ncm { } - Result ContentMetaDatabaseInterface::GetContentIdByTypeImpl(ContentId* out, const ContentMetaKey& key, ContentType type, std::optional id_offset) { + Result ContentMetaDatabaseInterface::GetContentIdByTypeImpl(ContentId *out, const ContentMetaKey& key, ContentType type, std::optional id_offset) { R_TRY(this->EnsureEnabled()); const auto it = this->kvs->lower_bound(key); @@ -96,7 +96,7 @@ namespace ams::ncm { R_UNLESS(it->GetKey().id == key.id, ncm::ResultContentMetaNotFound()); const auto stored_key = it->GetKey(); - const void* value = nullptr; + const void *value = nullptr; size_t value_size = 0; R_TRY(GetContentMetaValuePointer(&value, &value_size, stored_key, this->kvs)); @@ -104,12 +104,12 @@ namespace ams::ncm { R_UNLESS(header->content_count != 0, ncm::ResultContentNotFound()); - const ContentInfo* content_infos = GetValueContentInfos(value); - const ContentInfo* found_content_info = nullptr; + const ContentInfo *content_infos = GetValueContentInfos(value); + const ContentInfo *found_content_info = nullptr; if (id_offset) { for (size_t i = 0; i < header->content_count; i++) { - const ContentInfo* content_info = &content_infos[i]; + const ContentInfo *content_info = &content_infos[i]; if (content_info->content_type == type && content_info->id_offset == *id_offset) { found_content_info = content_info; @@ -117,10 +117,10 @@ namespace ams::ncm { } } } else { - const ContentInfo* lowest_id_offset_info = nullptr; + const ContentInfo *lowest_id_offset_info = nullptr; for (size_t i = 0; i < header->content_count; i++) { - const ContentInfo* content_info = &content_infos[i]; + const ContentInfo *content_info = &content_infos[i]; if (content_info->content_type == type && (!lowest_id_offset_info || lowest_id_offset_info->id_offset > content_info->id_offset)) { lowest_id_offset_info = content_info; @@ -135,7 +135,7 @@ namespace ams::ncm { return ResultSuccess(); } - Result ContentMetaDatabaseInterface::GetLatestContentMetaKeyImpl(ContentMetaKey* out_key, ProgramId id) { + Result ContentMetaDatabaseInterface::GetLatestContentMetaKeyImpl(ContentMetaKey *out_key, ProgramId id) { R_TRY(this->EnsureEnabled()); ContentMetaKey key = {0}; @@ -224,7 +224,7 @@ namespace ams::ncm { } if (static_cast(application_program_id) != 0) { - const void* value = nullptr; + const void *value = nullptr; size_t value_size = 0; R_TRY(GetContentMetaValuePointer(&value, &value_size, key, this->kvs)); @@ -290,7 +290,7 @@ namespace ams::ncm { continue; } - const void* value = nullptr; + const void *value = nullptr; size_t value_size = 0; R_TRY(GetContentMetaValuePointer(&value, &value_size, key, this->kvs)); @@ -307,7 +307,7 @@ namespace ams::ncm { /* Write the entry to the output buffer. */ if (entries_written < out_keys.GetSize()) { - ApplicationContentMetaKey* out_app_key = &out_keys[entries_written]; + ApplicationContentMetaKey *out_app_key = &out_keys[entries_written]; out_app_key->application_program_id = application_id; out_app_key->key = key; entries_written++; @@ -368,7 +368,7 @@ namespace ams::ncm { R_TRY(this->EnsureEnabled()); R_UNLESS(key.type == ContentMetaType::Application || key.type == ContentMetaType::Patch, ncm::ResultInvalidContentMetaKey()); - const void* value = nullptr; + const void *value = nullptr; size_t value_size = 0; R_TRY(GetContentMetaValuePointer(&value, &value_size, key, this->kvs)); @@ -383,7 +383,7 @@ namespace ams::ncm { R_TRY(this->EnsureEnabled()); R_UNLESS(key.type == ContentMetaType::Application, ncm::ResultInvalidContentMetaKey()); - const void* value = nullptr; + const void *value = nullptr; size_t value_size = 0; R_TRY(GetContentMetaValuePointer(&value, &value_size, key, this->kvs)); const auto ext_header = GetValueExtendedHeader(value); @@ -420,9 +420,9 @@ namespace ams::ncm { continue; } - const ContentInfo* content_infos = GetValueContentInfos(value); + const ContentInfo *content_infos = GetValueContentInfos(value); for (size_t i = 0; i < header->content_count; i++) { - const ContentInfo* content_info = &content_infos[i]; + const ContentInfo *content_info = &content_infos[i]; /* Check if any of this entry's content infos matches one of the provided content ids. If they do, then the content id isn't orphaned. */ @@ -448,15 +448,15 @@ namespace ams::ncm { } Result ContentMetaDatabaseInterface::HasContent(sf::Out out, ContentMetaKey key, ContentId content_id) { - const void* value = nullptr; + const void *value = nullptr; size_t value_size = 0; R_TRY(GetContentMetaValuePointer(&value, &value_size, key, this->kvs)); const auto header = GetValueHeader(value); - const ContentInfo* content_infos = GetValueContentInfos(value); + const ContentInfo *content_infos = GetValueContentInfos(value); if (header->content_count > 0) { for (size_t i = 0; i < header->content_count; i++) { - const ContentInfo* content_info = &content_infos[i]; + const ContentInfo *content_info = &content_infos[i]; if (content_id == content_info->content_id) { out.SetValue(false); @@ -473,7 +473,7 @@ namespace ams::ncm { R_UNLESS(start_index <= std::numeric_limits::max(), ncm::ResultInvalidOffset()); R_TRY(this->EnsureEnabled()); - const void* value = nullptr; + const void *value = nullptr; size_t value_size = 0; R_TRY(GetContentMetaValuePointer(&value, &value_size, key, this->kvs)); const auto header = GetValueHeader(value); @@ -502,7 +502,7 @@ namespace ams::ncm { Result ContentMetaDatabaseInterface::GetAttributes(sf::Out out_attributes, ContentMetaKey key) { R_TRY(this->EnsureEnabled()); - const void* value = nullptr; + const void *value = nullptr; size_t value_size = 0; R_TRY(GetContentMetaValuePointer(&value, &value_size, key, this->kvs)); const auto header = GetValueHeader(value); @@ -513,7 +513,7 @@ namespace ams::ncm { Result ContentMetaDatabaseInterface::GetRequiredApplicationVersion(sf::Out out_version, ContentMetaKey key) { R_TRY(this->EnsureEnabled()); - const void* value = nullptr; + const void *value = nullptr; size_t value_size = 0; R_TRY(GetContentMetaValuePointer(&value, &value_size, key, this->kvs)); @@ -537,7 +537,7 @@ namespace ams::ncm { return ResultSuccess(); } - Result ContentMetaDatabaseInterface::GetLatestProgram(ContentId* out_content_id, ProgramId program_id) { + Result ContentMetaDatabaseInterface::GetLatestProgram(ContentId *out_content_id, ProgramId program_id) { ContentMetaKey key; R_TRY(this->GetLatestContentMetaKey(&key, program_id)); @@ -545,7 +545,7 @@ namespace ams::ncm { return ResultSuccess(); } - Result ContentMetaDatabaseInterface::GetLatestData(ContentId* out_content_id, ProgramId program_id) { + Result ContentMetaDatabaseInterface::GetLatestData(ContentId *out_content_id, ProgramId program_id) { ContentMetaKey key; R_TRY(this->GetLatestContentMetaKey(&key, program_id)); diff --git a/stratosphere/ncm/source/ncm_content_meta_database.hpp b/stratosphere/ncm/source/ncm_content_meta_database.hpp index 5f2b575b8..fbb8dad00 100644 --- a/stratosphere/ncm/source/ncm_content_meta_database.hpp +++ b/stratosphere/ncm/source/ncm_content_meta_database.hpp @@ -22,13 +22,13 @@ namespace ams::ncm { class ContentMetaDatabaseInterface : public IContentMetaDatabase { public: - ContentMetaDatabaseInterface(ams::kvdb::MemoryKeyValueStore* kvs, const char* mount_name) : IContentMetaDatabase(kvs, mount_name) { + ContentMetaDatabaseInterface(ams::kvdb::MemoryKeyValueStore *kvs, const char *mount_name) : IContentMetaDatabase(kvs, mount_name) { } - ContentMetaDatabaseInterface(ams::kvdb::MemoryKeyValueStore* kvs) : IContentMetaDatabase(kvs) { + ContentMetaDatabaseInterface(ams::kvdb::MemoryKeyValueStore *kvs) : IContentMetaDatabase(kvs) { } private: - Result GetContentIdByTypeImpl(ContentId* out, const ContentMetaKey& key, ContentType type, std::optional id_offset); - Result GetLatestContentMetaKeyImpl(ContentMetaKey* out_key, ProgramId id); + Result GetContentIdByTypeImpl(ContentId *out, const ContentMetaKey& key, ContentType type, std::optional id_offset); + Result GetLatestContentMetaKeyImpl(ContentMetaKey *out_key, ProgramId id); public: virtual Result Set(ContentMetaKey key, sf::InBuffer value) override; virtual Result Get(sf::Out out_size, ContentMetaKey key, sf::OutBuffer out_value) override; @@ -53,13 +53,13 @@ namespace ams::ncm { virtual Result GetContentIdByTypeAndIdOffset(sf::Out out_content_id, ContentMetaKey key, ContentType type, u8 id_offset) override; /* APIs. */ - virtual Result GetLatestProgram(ContentId* out_content_id, ProgramId program_id) override; - virtual Result GetLatestData(ContentId* out_content_id, ProgramId program_id) override; + virtual Result GetLatestProgram(ContentId *out_content_id, ProgramId program_id) override; + virtual Result GetLatestData(ContentId *out_content_id, ProgramId program_id) override; }; class OnMemoryContentMetaDatabaseInterface : public ContentMetaDatabaseInterface { public: - OnMemoryContentMetaDatabaseInterface(ams::kvdb::MemoryKeyValueStore* kvs) : ContentMetaDatabaseInterface(kvs) { + OnMemoryContentMetaDatabaseInterface(ams::kvdb::MemoryKeyValueStore *kvs) : ContentMetaDatabaseInterface(kvs) { } public: virtual Result GetLatestContentMetaKey(sf::Out out_key, ProgramId id) override; diff --git a/stratosphere/ncm/source/ncm_content_storage.cpp b/stratosphere/ncm/source/ncm_content_storage.cpp index 92bb6ca62..d31188946 100644 --- a/stratosphere/ncm/source/ncm_content_storage.cpp +++ b/stratosphere/ncm/source/ncm_content_storage.cpp @@ -25,7 +25,7 @@ namespace ams::ncm { this->Finalize(); } - Result ContentStorageInterface::Initialize(const char* root_path, MakeContentPathFunc content_path_func, MakePlaceHolderPathFunc placeholder_path_func, bool delay_flush, impl::RightsIdCache* rights_id_cache) { + Result ContentStorageInterface::Initialize(const char *root_path, MakeContentPathFunc content_path_func, MakePlaceHolderPathFunc placeholder_path_func, bool delay_flush, impl::RightsIdCache *rights_id_cache) { R_TRY(this->EnsureEnabled()); R_TRY(fs::CheckContentStorageDirectoriesExist(root_path)); const size_t root_path_len = strnlen(root_path, FS_MAX_PATH-1); @@ -217,7 +217,7 @@ namespace ams::ncm { const unsigned int dir_depth = this->placeholder_accessor.GetDirectoryDepth(); size_t entry_count = 0; - R_TRY(fs::TraverseDirectory(placeholder_root_path, dir_depth, [&](bool* should_continue, bool* should_retry_dir_read, const char* current_path, struct dirent* dir_entry) -> Result { + R_TRY(fs::TraverseDirectory(placeholder_root_path, dir_depth, [&](bool *should_continue, bool *should_retry_dir_read, const char *current_path, struct dirent *dir_entry) -> Result { *should_continue = true; *should_retry_dir_read = false; @@ -244,7 +244,7 @@ namespace ams::ncm { const unsigned int dir_depth = this->GetContentDirectoryDepth(); u32 content_count = 0; - R_TRY(fs::TraverseDirectory(content_root_path, dir_depth, [&](bool* should_continue, bool* should_retry_dir_read, const char* current_path, struct dirent* dir_entry) -> Result { + R_TRY(fs::TraverseDirectory(content_root_path, dir_depth, [&](bool *should_continue, bool *should_retry_dir_read, const char *current_path, struct dirent *dir_entry) -> Result { *should_continue = true; *should_retry_dir_read = false; @@ -268,7 +268,7 @@ namespace ams::ncm { const unsigned int dir_depth = this->GetContentDirectoryDepth(); size_t entry_count = 0; - R_TRY(fs::TraverseDirectory(content_root_path, dir_depth, [&](bool* should_continue, bool* should_retry_dir_read, const char* current_path, struct dirent* dir_entry) { + R_TRY(fs::TraverseDirectory(content_root_path, dir_depth, [&](bool *should_continue, bool *should_retry_dir_read, const char *current_path, struct dirent *dir_entry) { *should_retry_dir_read = false; *should_continue = true; @@ -396,7 +396,7 @@ namespace ams::ncm { /* Attempt to locate the content id in the cache. */ for (size_t i = 0; i < impl::RightsIdCache::MaxEntries; i++) { - impl::RightsIdCache::Entry* entry = &this->rights_id_cache->entries[i]; + impl::RightsIdCache::Entry *entry = &this->rights_id_cache->entries[i]; if (entry->last_accessed != 1 && content_id == entry->uuid) { entry->last_accessed = this->rights_id_cache->counter; @@ -418,11 +418,11 @@ namespace ams::ncm { { std::scoped_lock lk(this->rights_id_cache->mutex); - impl::RightsIdCache::Entry* eviction_candidate = &this->rights_id_cache->entries[0]; + impl::RightsIdCache::Entry *eviction_candidate = &this->rights_id_cache->entries[0]; /* Find a suitable existing entry to store our new one at. */ for (size_t i = 1; i < impl::RightsIdCache::MaxEntries; i++) { - impl::RightsIdCache::Entry* entry = &this->rights_id_cache->entries[i]; + impl::RightsIdCache::Entry *entry = &this->rights_id_cache->entries[i]; /* Change eviction candidates if the uuid already matches ours, or if the uuid doesn't already match and the last_accessed count is lower */ if (content_id == entry->uuid || (content_id != eviction_candidate->uuid && entry->last_accessed < eviction_candidate->last_accessed)) { @@ -460,7 +460,7 @@ namespace ams::ncm { char content_path[FS_MAX_PATH] = {0}; this->GetContentPath(content_path, content_id); - FILE* f = nullptr; + FILE *f = nullptr; R_TRY(fs::OpenFile(&f, content_path, FsOpenMode_Write)); ON_SCOPE_EXIT { @@ -518,7 +518,7 @@ namespace ams::ncm { char content_root_path[FS_MAX_PATH] = {0}; this->GetContentRootPath(content_root_path); unsigned int dir_depth = this->GetContentDirectoryDepth(); - auto fix_file_attributes = [&](bool* should_continue, bool* should_retry_dir_read, const char* current_path, struct dirent* dir_entry) { + auto fix_file_attributes = [&](bool *should_continue, bool *should_retry_dir_read, const char *current_path, struct dirent *dir_entry) { *should_retry_dir_read = false; *should_continue = true; @@ -553,7 +553,7 @@ namespace ams::ncm { /* Attempt to locate the content id in the cache. */ for (size_t i = 0; i < impl::RightsIdCache::MaxEntries; i++) { - impl::RightsIdCache::Entry* entry = &this->rights_id_cache->entries[i]; + impl::RightsIdCache::Entry *entry = &this->rights_id_cache->entries[i]; if (entry->last_accessed != 1 && cache_content_id == entry->uuid) { entry->last_accessed = this->rights_id_cache->counter; @@ -575,11 +575,11 @@ namespace ams::ncm { { std::scoped_lock lk(this->rights_id_cache->mutex); - impl::RightsIdCache::Entry* eviction_candidate = &this->rights_id_cache->entries[0]; + impl::RightsIdCache::Entry *eviction_candidate = &this->rights_id_cache->entries[0]; /* Find a suitable existing entry to store our new one at. */ for (size_t i = 1; i < impl::RightsIdCache::MaxEntries; i++) { - impl::RightsIdCache::Entry* entry = &this->rights_id_cache->entries[i]; + impl::RightsIdCache::Entry *entry = &this->rights_id_cache->entries[i]; /* Change eviction candidates if the uuid already matches ours, or if the uuid doesn't already match and the last_accessed count is lower */ if (cache_content_id == entry->uuid || (cache_content_id != eviction_candidate->uuid && entry->last_accessed < eviction_candidate->last_accessed)) { diff --git a/stratosphere/ncm/source/ncm_content_storage.hpp b/stratosphere/ncm/source/ncm_content_storage.hpp index fa7b9b140..bfa7468e1 100644 --- a/stratosphere/ncm/source/ncm_content_storage.hpp +++ b/stratosphere/ncm/source/ncm_content_storage.hpp @@ -28,23 +28,23 @@ namespace ams::ncm { protected: impl::PlaceHolderAccessor placeholder_accessor; ContentId cached_content_id; - FILE* content_cache_file_handle; - impl::RightsIdCache* rights_id_cache; + FILE *content_cache_file_handle; + impl::RightsIdCache *rights_id_cache; public: ~ContentStorageInterface(); - Result Initialize(const char* root_path, MakeContentPathFunc content_path_func, MakePlaceHolderPathFunc placeholder_path_func, bool delay_flush, impl::RightsIdCache* rights_id_cache); + Result Initialize(const char *root_path, MakeContentPathFunc content_path_func, MakePlaceHolderPathFunc placeholder_path_func, bool delay_flush, impl::RightsIdCache *rights_id_cache); void Finalize(); private: void ClearContentCache(); unsigned int GetContentDirectoryDepth(); Result OpenCachedContentFile(ContentId content_id); - inline void GetContentRootPath(char* out_content_root) { + inline void GetContentRootPath(char *out_content_root) { path::GetContentRootPath(out_content_root, this->root_path); } - inline void GetContentPath(char* out_content_path, ContentId content_id) { + inline void GetContentPath(char *out_content_path, ContentId content_id) { char content_root_path[FS_MAX_PATH] = {0}; this->GetContentRootPath(content_root_path); diff --git a/stratosphere/ncm/source/ncm_fs.cpp b/stratosphere/ncm/source/ncm_fs.cpp index 648472d25..2658ff3a0 100644 --- a/stratosphere/ncm/source/ncm_fs.cpp +++ b/stratosphere/ncm/source/ncm_fs.cpp @@ -23,28 +23,28 @@ namespace ams::ncm::fs { - Result OpenFile(FILE** out, const char* path, u32 mode) { + Result OpenFile(FILE** out, const char *path, u32 mode) { bool has = false; /* Manually check if the file already exists, so it doesn't get created automatically. */ R_TRY(HasFile(&has, path)); R_UNLESS(has, ams::fs::ResultPathNotFound()); - const char* fopen_mode = ""; + const char *fopen_mode = ""; if (mode & FsOpenMode_Write) { fopen_mode = "r+b"; } else if (mode & FsOpenMode_Read) { fopen_mode = "rb"; } - FILE* f = fopen(path, fopen_mode); + FILE *f = fopen(path, fopen_mode); R_UNLESS(f != nullptr, fsdevGetLastResult()); *out = f; return ResultSuccess(); } - Result WriteFile(FILE* f, size_t offset, const void* buffer, size_t size, u32 option) { + Result WriteFile(FILE *f, size_t offset, const void *buffer, size_t size, u32 option) { R_UNLESS(fseek(f, 0, SEEK_END) == 0, fsdevGetLastResult()); size_t existing_size = ftell(f); @@ -59,14 +59,14 @@ namespace ams::ncm::fs { return ResultSuccess(); } - Result ReadFile(FILE* f, size_t offset, void* buffer, size_t size) { + Result ReadFile(FILE *f, size_t offset, void *buffer, size_t size) { R_UNLESS(fseek(f, offset, SEEK_SET) == 0, fsdevGetLastResult()); R_UNLESS(fread(buffer, 1, size, f) == size, fsdevGetLastResult()); R_UNLESS(!ferror(f), fsdevGetLastResult()); return ResultSuccess(); } - Result HasFile(bool* out, const char* path) { + Result HasFile(bool *out, const char *path) { struct stat st; if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) { @@ -82,7 +82,7 @@ namespace ams::ncm::fs { return ResultSuccess(); } - Result HasDirectory(bool* out, const char* path) { + Result HasDirectory(bool *out, const char *path) { struct stat st; if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) { @@ -98,7 +98,7 @@ namespace ams::ncm::fs { return ResultSuccess(); } - Result CheckContentStorageDirectoriesExist(const char* root_path) { + Result CheckContentStorageDirectoriesExist(const char *root_path) { char content_root[FS_MAX_PATH] = {0}; char placeholder_root[FS_MAX_PATH] = {0}; @@ -119,7 +119,7 @@ namespace ams::ncm::fs { return ResultSuccess(); } - Result EnsureContentAndPlaceHolderRoot(const char* root_path) { + Result EnsureContentAndPlaceHolderRoot(const char *root_path) { char content_root[FS_MAX_PATH] = {0}; char placeholder_root[FS_MAX_PATH] = {0}; @@ -131,7 +131,7 @@ namespace ams::ncm::fs { return ResultSuccess(); } - Result EnsureDirectoryRecursively(const char* dir_path) { + Result EnsureDirectoryRecursively(const char *dir_path) { R_TRY(EnsureRecursively(dir_path)); if (mkdir(dir_path, S_IRWXU) == -1) { R_TRY_CATCH(fsdevGetLastResult()) { @@ -143,7 +143,7 @@ namespace ams::ncm::fs { return ResultSuccess(); } - Result EnsureRecursively(const char* path) { + Result EnsureRecursively(const char *path) { R_UNLESS(path, ams::fs::ResultNullptrArgument()); size_t path_len = strlen(path); @@ -174,11 +174,11 @@ namespace ams::ncm::fs { return ResultSuccess(); } - Result EnsureParentDirectoryRecursively(const char* path) { + Result EnsureParentDirectoryRecursively(const char *path) { return EnsureRecursively(path); } - Result GetGameCardHandle(FsGameCardHandle* out_handle) { + Result GetGameCardHandle(FsGameCardHandle *out_handle) { FsDeviceOperator devop; R_TRY(fsOpenDeviceOperator(&devop)); @@ -200,8 +200,8 @@ namespace ams::ncm::fs { return mount_name; } - Result GetMountNameFromPath(MountName* mount_name, const char* path) { - const char* unqual_path = strchr(path, ':'); + Result GetMountNameFromPath(MountName *mount_name, const char *path) { + const char *unqual_path = strchr(path, ':'); /* We should be given a qualified path. */ R_UNLESS(unqual_path, ams::fs::ResultInvalidMountName()); @@ -211,7 +211,7 @@ namespace ams::ncm::fs { return ResultSuccess(); } - Result MountSystemSaveData(const char* mount_point, FsSaveDataSpaceId space_id, u64 save_id) { + Result MountSystemSaveData(const char *mount_point, FsSaveDataSpaceId space_id, u64 save_id) { R_UNLESS(mount_point, ams::fs::ResultNullptrArgument()); FsSaveDataAttribute save = { @@ -226,17 +226,17 @@ namespace ams::ncm::fs { return ResultSuccess(); } - constexpr const char* SystemContentMountName = "@SystemContent"; - constexpr const char* UserContentMountName = "@UserContent"; - constexpr const char* SdCardContentMountName = "@SdCardContent"; - constexpr const char* GameCardMountNameBase = "@Gc"; + constexpr const char *SystemContentMountName = "@SystemContent"; + constexpr const char *UserContentMountName = "@UserContent"; + constexpr const char *SdCardContentMountName = "@SdCardContent"; + constexpr const char *GameCardMountNameBase = "@Gc"; - constexpr const char* GameCardPartitionLetters[3] = { "U", "N", "S" }; + constexpr const char *GameCardPartitionLetters[3] = { "U", "N", "S" }; /* Maps mount names to their common mount names. */ std::map g_mount_content_storage; - Result MountContentStorage(const char* mount_point, FsContentStorageId id) { + Result MountContentStorage(const char *mount_point, FsContentStorageId id) { R_UNLESS(mount_point, ams::fs::ResultNullptrArgument()); FsFileSystem fs; @@ -262,7 +262,7 @@ namespace ams::ncm::fs { return ResultSuccess(); } - Result MountGameCardPartition(const char* mount_point, const FsGameCardHandle handle, FsGameCardPartition partition) { + Result MountGameCardPartition(const char *mount_point, const FsGameCardHandle handle, FsGameCardPartition partition) { AMS_ABORT_UNLESS(partition <= 2); FsFileSystem fs; @@ -275,7 +275,7 @@ namespace ams::ncm::fs { return ResultSuccess(); } - Result Unmount(const char* mount_point) { + Result Unmount(const char *mount_point) { R_UNLESS(mount_point, ams::fs::ResultNullptrArgument()); /* Erase any content storage mappings which may potentially exist. */ g_mount_content_storage.erase(mount_point); @@ -283,7 +283,7 @@ namespace ams::ncm::fs { return ResultSuccess(); } - Result ConvertToFsCommonPath(char* out_common_path, size_t out_len, const char* path) { + Result ConvertToFsCommonPath(char *out_common_path, size_t out_len, const char *path) { R_UNLESS(out_common_path, ams::fs::ResultNullptrArgument()); R_UNLESS(path, ams::fs::ResultNullptrArgument()); @@ -300,7 +300,7 @@ namespace ams::ncm::fs { return ResultSuccess(); } - Result GetSaveDataFlags(u32* out_flags, u64 save_id) { + Result GetSaveDataFlags(u32 *out_flags, u64 save_id) { FsSaveDataExtraData extra_data; R_TRY(fsReadSaveDataFileSystemExtraData(&extra_data, sizeof(FsSaveDataExtraData), save_id)); diff --git a/stratosphere/ncm/source/ncm_fs.hpp b/stratosphere/ncm/source/ncm_fs.hpp index 14efb03aa..ee68e4fe7 100644 --- a/stratosphere/ncm/source/ncm_fs.hpp +++ b/stratosphere/ncm/source/ncm_fs.hpp @@ -21,39 +21,39 @@ namespace ams::ncm::fs { - Result OpenFile(FILE** out, const char* path, u32 mode); - Result WriteFile(FILE* f, size_t offset, const void* buffer, size_t size, u32 option); - Result ReadFile(FILE* f, size_t offset, void* buffer, size_t size); + Result OpenFile(FILE** out, const char *path, u32 mode); + Result WriteFile(FILE *f, size_t offset, const void *buffer, size_t size, u32 option); + Result ReadFile(FILE *f, size_t offset, void *buffer, size_t size); - Result HasFile(bool* out, const char* path); - Result HasDirectory(bool* out, const char* path); + Result HasFile(bool *out, const char *path); + Result HasDirectory(bool *out, const char *path); - Result CheckContentStorageDirectoriesExist(const char* root_path); - Result EnsureContentAndPlaceHolderRoot(const char* root_path); + Result CheckContentStorageDirectoriesExist(const char *root_path); + Result EnsureContentAndPlaceHolderRoot(const char *root_path); - Result EnsureDirectoryRecursively(const char* dir_path); - Result EnsureRecursively(const char* path); + Result EnsureDirectoryRecursively(const char *dir_path); + Result EnsureRecursively(const char *path); /* Create all parent directories for a file path */ - Result EnsureParentDirectoryRecursively(const char* path); + Result EnsureParentDirectoryRecursively(const char *path); - Result GetGameCardHandle(FsGameCardHandle* out_handle); + Result GetGameCardHandle(FsGameCardHandle *out_handle); MountName CreateUniqueMountName(); - Result GetMountNameFromPath(MountName* mount_name, const char* path); + Result GetMountNameFromPath(MountName *mount_name, const char *path); - Result MountSystemSaveData(const char* mount_point, FsSaveDataSpaceId space_id, u64 save_id); - Result MountContentStorage(const char* mount_point, FsContentStorageId id); - Result MountGameCardPartition(const char* mount_point, const FsGameCardHandle handle, FsGameCardPartition partition); - Result Unmount(const char* mount_point); - Result ConvertToFsCommonPath(char* out_common_path, size_t len, const char* path); + Result MountSystemSaveData(const char *mount_point, FsSaveDataSpaceId space_id, u64 save_id); + Result MountContentStorage(const char *mount_point, FsContentStorageId id); + Result MountGameCardPartition(const char *mount_point, const FsGameCardHandle handle, FsGameCardPartition partition); + Result Unmount(const char *mount_point); + Result ConvertToFsCommonPath(char *out_common_path, size_t len, const char *path); - Result GetSaveDataFlags(u32* out_flags, u64 save_id); + Result GetSaveDataFlags(u32 *out_flags, u64 save_id); Result SetSaveDataFlags(u64 save_id, FsSaveDataSpaceId space_id, u32 flags); template - Result TraverseDirectory(bool* out_should_continue, const char* root_path, int max_level, F f) { + Result TraverseDirectory(bool *out_should_continue, const char *root_path, int max_level, F f) { DIR *dir; - struct dirent* dir_entry = nullptr; + struct dirent *dir_entry = nullptr; R_UNLESS(max_level >= 1, ResultSuccess()); bool retry_dir_read = true; @@ -100,7 +100,7 @@ namespace ams::ncm::fs { }; template - Result TraverseDirectory(const char* root_path, int max_level, F f) { + Result TraverseDirectory(const char *root_path, int max_level, F f) { bool should_continue = false; return TraverseDirectory(&should_continue, root_path, max_level, f); } diff --git a/stratosphere/ncm/source/ncm_main.cpp b/stratosphere/ncm/source/ncm_main.cpp index cb70a54a6..237726111 100644 --- a/stratosphere/ncm/source/ncm_main.cpp +++ b/stratosphere/ncm/source/ncm_main.cpp @@ -58,12 +58,12 @@ void __libnx_exception_handler(ThreadExceptionDump *ctx) { } void __libnx_initheap(void) { - void* addr = nx_inner_heap; + void * addr = nx_inner_heap; size_t size = nx_inner_heap_size; /* Newlib */ - extern char* fake_heap_start; - extern char* fake_heap_end; + extern char *fake_heap_start; + extern char *fake_heap_end; fake_heap_start = (char*)addr; fake_heap_end = (char*)addr + size; @@ -153,7 +153,7 @@ namespace { } -void ContentManagerServerMain(void* arg) { +void ContentManagerServerMain(void *arg) { /* Create services. */ R_ABORT_UNLESS(g_ncm_server_manager.RegisterServer(ContentManagerServiceName, ContentManagerManagerSessions)); diff --git a/stratosphere/ncm/source/ncm_make_path.cpp b/stratosphere/ncm/source/ncm_make_path.cpp index 65d06dc8f..1a4dee1a9 100644 --- a/stratosphere/ncm/source/ncm_make_path.cpp +++ b/stratosphere/ncm/source/ncm_make_path.cpp @@ -35,13 +35,13 @@ namespace ams::ncm::path { } - void MakeContentPathFlat(char* path_out, ContentId content_id, const char* root) { + void MakeContentPathFlat(char *path_out, ContentId content_id, const char *root) { char content_name[FS_MAX_PATH] = {0}; GetContentFileName(content_name, content_id); AMS_ABORT_UNLESS(snprintf(path_out, FS_MAX_PATH-1, "%s/%s", root, content_name) >= 0); } - void MakeContentPathDualLayered(char* path_out, ContentId content_id, const char* root) { + void MakeContentPathDualLayered(char *path_out, ContentId content_id, const char *root) { char content_name[FS_MAX_PATH] = {0}; const u16 hash = Get16BitSha256HashPrefix(content_id.uuid); const u32 hash_lower = (hash >> 4) & 0x3f; @@ -51,27 +51,27 @@ namespace ams::ncm::path { AMS_ABORT_UNLESS(snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%08X/%s", root, hash_upper, hash_lower, content_name) >= 0); } - void MakeContentPath10BitLayered(char* path_out, ContentId content_id, const char* root) { + void MakeContentPath10BitLayered(char *path_out, ContentId content_id, const char *root) { char content_name[FS_MAX_PATH] = {0}; const u32 hash = (Get16BitSha256HashPrefix(content_id.uuid) >> 6) & 0x3FF; GetContentFileName(content_name, content_id); AMS_ABORT_UNLESS(snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash, content_name) >= 0); } - void MakeContentPathHashByteLayered(char* path_out, ContentId content_id, const char* root) { + void MakeContentPathHashByteLayered(char *path_out, ContentId content_id, const char *root) { char content_name[FS_MAX_PATH] = {0}; const u32 hash_byte = static_cast(Get8BitSha256HashPrefix(content_id.uuid)); GetContentFileName(content_name, content_id); AMS_ABORT_UNLESS(snprintf(path_out, FS_MAX_PATH-1, "%s/%08X/%s", root, hash_byte, content_name) >= 0); } - void MakePlaceHolderPathFlat(char* path_out, PlaceHolderId placeholder_id, const char* root) { + void MakePlaceHolderPathFlat(char *path_out, PlaceHolderId placeholder_id, const char *root) { char placeholder_name[FS_MAX_PATH] = {0}; GetPlaceHolderFileName(placeholder_name, placeholder_id); AMS_ABORT_UNLESS(snprintf(path_out, FS_MAX_PATH-1, "%s/%s", root, placeholder_name) >= 0); } - void MakePlaceHolderPathHashByteLayered(char* path_out, PlaceHolderId placeholder_id, const char* root) { + void MakePlaceHolderPathHashByteLayered(char *path_out, PlaceHolderId placeholder_id, const char *root) { char placeholder_name[FS_MAX_PATH] = {0}; const u32 hash_byte = static_cast(Get8BitSha256HashPrefix(placeholder_id.uuid)); GetPlaceHolderFileName(placeholder_name, placeholder_id); diff --git a/stratosphere/ncm/source/ncm_make_path.hpp b/stratosphere/ncm/source/ncm_make_path.hpp index d8f1f9139..cc316ad28 100644 --- a/stratosphere/ncm/source/ncm_make_path.hpp +++ b/stratosphere/ncm/source/ncm_make_path.hpp @@ -20,12 +20,12 @@ namespace ams::ncm::path { - void MakeContentPathFlat(char* out_path, ContentId content_id, const char* root); - void MakeContentPathHashByteLayered(char* out_path, ContentId content_id, const char* root); - void MakeContentPath10BitLayered(char* out_path, ContentId content_id, const char* root); - void MakeContentPathDualLayered(char* out_path, ContentId content_id, const char* root); + void MakeContentPathFlat(char *out_path, ContentId content_id, const char *root); + void MakeContentPathHashByteLayered(char *out_path, ContentId content_id, const char *root); + void MakeContentPath10BitLayered(char *out_path, ContentId content_id, const char *root); + void MakeContentPathDualLayered(char *out_path, ContentId content_id, const char *root); - void MakePlaceHolderPathFlat(char* out_path, PlaceHolderId placeholder_id, const char* root); - void MakePlaceHolderPathHashByteLayered(char* out_path, PlaceHolderId placeholder_id, const char* root); + void MakePlaceHolderPathFlat(char *out_path, PlaceHolderId placeholder_id, const char *root); + void MakePlaceHolderPathHashByteLayered(char *out_path, PlaceHolderId placeholder_id, const char *root); } diff --git a/stratosphere/ncm/source/ncm_path_utils.cpp b/stratosphere/ncm/source/ncm_path_utils.cpp index fe5487e3b..d001042a6 100644 --- a/stratosphere/ncm/source/ncm_path_utils.cpp +++ b/stratosphere/ncm/source/ncm_path_utils.cpp @@ -19,7 +19,7 @@ namespace ams::ncm::path { - void GetContentMetaPath(char* out, ContentId content_id, MakeContentPathFunc path_func, const char* root_path) { + void GetContentMetaPath(char *out, ContentId content_id, MakeContentPathFunc path_func, const char *root_path) { char tmp_path[FS_MAX_PATH-1] = {0}; char content_path[FS_MAX_PATH-1] = {0}; path_func(content_path, content_id, root_path); @@ -37,19 +37,19 @@ namespace ams::ncm::path { strncat(out, ".cnmt.nca", 0x2ff - out_len); } - void GetContentFileName(char* out, ContentId content_id) { + void GetContentFileName(char *out, ContentId content_id) { char content_name[sizeof(ContentId)*2+1] = {0}; GetStringFromContentId(content_name, content_id); snprintf(out, FS_MAX_PATH-1, "%s%s", content_name, ".nca"); } - void GetPlaceHolderFileName(char* out, PlaceHolderId placeholder_id) { + void GetPlaceHolderFileName(char *out, PlaceHolderId placeholder_id) { char placeholder_name[sizeof(PlaceHolderId)*2+1] = {0}; GetStringFromPlaceHolderId(placeholder_name, placeholder_id); snprintf(out, FS_MAX_PATH-1, "%s%s", placeholder_name, ".nca"); } - bool IsNcaPath(const char* path) { + bool IsNcaPath(const char *path) { PathView path_view(path); if (!path_view.HasSuffix(".nca")) { diff --git a/stratosphere/ncm/source/ncm_path_utils.hpp b/stratosphere/ncm/source/ncm_path_utils.hpp index d26590d7e..560d560f4 100644 --- a/stratosphere/ncm/source/ncm_path_utils.hpp +++ b/stratosphere/ncm/source/ncm_path_utils.hpp @@ -20,20 +20,20 @@ namespace ams::ncm::path { - inline void GetContentRootPath(char* out_content_root, const char* root_path) { + inline void GetContentRootPath(char *out_content_root, const char *root_path) { /* TODO: Replace with BoundedString? */ AMS_ABORT_UNLESS(snprintf(out_content_root, FS_MAX_PATH-1, "%s%s", root_path, "/registered") >= 0); } - inline void GetPlaceHolderRootPath(char* out_placeholder_root, const char* root_path) { + inline void GetPlaceHolderRootPath(char *out_placeholder_root, const char *root_path) { /* TODO: Replace with BoundedString? */ AMS_ABORT_UNLESS(snprintf(out_placeholder_root, FS_MAX_PATH, "%s%s", root_path, "/placehld") >= 0); } - void GetContentMetaPath(char* out, ContentId content_id, MakeContentPathFunc path_func, const char* root_path); - void GetContentFileName(char* out, ContentId content_id); - void GetPlaceHolderFileName(char* out, PlaceHolderId placeholder_id); - bool IsNcaPath(const char* path); + void GetContentMetaPath(char *out, ContentId content_id, MakeContentPathFunc path_func, const char *root_path); + void GetContentFileName(char *out, ContentId content_id); + void GetPlaceHolderFileName(char *out, PlaceHolderId placeholder_id); + bool IsNcaPath(const char *path); class PathView { private: diff --git a/stratosphere/ncm/source/ncm_read_only_content_storage.cpp b/stratosphere/ncm/source/ncm_read_only_content_storage.cpp index 7f7406a37..21e5ec7cb 100644 --- a/stratosphere/ncm/source/ncm_read_only_content_storage.cpp +++ b/stratosphere/ncm/source/ncm_read_only_content_storage.cpp @@ -20,7 +20,7 @@ namespace ams::ncm { - Result ReadOnlyContentStorageInterface::Initialize(const char* root_path, MakeContentPathFunc content_path_func) { + Result ReadOnlyContentStorageInterface::Initialize(const char *root_path, MakeContentPathFunc content_path_func) { R_TRY(this->EnsureEnabled()); const size_t root_path_len = strnlen(root_path, FS_MAX_PATH-1); @@ -163,7 +163,7 @@ namespace ams::ncm { path::GetContentMetaPath(content_path, content_id, this->make_content_path_func, this->root_path); } - FILE* f = nullptr; + FILE *f = nullptr; R_TRY(fs::OpenFile(&f, content_path, FsOpenMode_Read)); ON_SCOPE_EXIT { diff --git a/stratosphere/ncm/source/ncm_read_only_content_storage.hpp b/stratosphere/ncm/source/ncm_read_only_content_storage.hpp index fee4b8cb6..8881f85b3 100644 --- a/stratosphere/ncm/source/ncm_read_only_content_storage.hpp +++ b/stratosphere/ncm/source/ncm_read_only_content_storage.hpp @@ -22,7 +22,7 @@ namespace ams::ncm { class ReadOnlyContentStorageInterface : public IContentStorage { public: - Result Initialize(const char* root_path, MakeContentPathFunc content_path_func); + Result Initialize(const char *root_path, MakeContentPathFunc content_path_func); public: virtual Result GeneratePlaceHolderId(sf::Out out) override; virtual Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, u64 size) override; diff --git a/stratosphere/ncm/source/ncm_utils.cpp b/stratosphere/ncm/source/ncm_utils.cpp index a954bf80a..22c1b200c 100644 --- a/stratosphere/ncm/source/ncm_utils.cpp +++ b/stratosphere/ncm/source/ncm_utils.cpp @@ -18,29 +18,29 @@ namespace ams::ncm { - void GetStringFromContentId(char* out, ContentId content_id) { + void GetStringFromContentId(char *out, ContentId content_id) { for (size_t i = 0; i < sizeof(ContentId); i++) { snprintf(out+i*2, 3, "%02x", content_id.uuid[i]); } } - void GetStringFromPlaceHolderId(char* out, PlaceHolderId placeholder_id) { + void GetStringFromPlaceHolderId(char *out, PlaceHolderId placeholder_id) { for (size_t i = 0; i < sizeof(PlaceHolderId); i++) { snprintf(out+i*2, 3, "%02x", placeholder_id.uuid[i]); } } - Result GetPlaceHolderIdFromDirEntry(PlaceHolderId* out, struct dirent* dir_entry) { + Result GetPlaceHolderIdFromDirEntry(PlaceHolderId *out, struct dirent *dir_entry) { R_UNLESS(strnlen(dir_entry->d_name, 0x30) == 0x24, ncm::ResultInvalidPlaceHolderFile()); R_UNLESS(strncmp(dir_entry->d_name + 0x20, ".nca", 4) == 0, ncm::ResultInvalidPlaceHolderFile()); u8 tmp[sizeof(PlaceHolderId)] = {}; char byte_string[2]; - char* end_ptr; + char *end_ptr; u64 converted_val; for (size_t i = 0; i < sizeof(PlaceHolderId); i++) { - char* name_char_pair = dir_entry->d_name + i * 2; + char *name_char_pair = dir_entry->d_name + i * 2; byte_string[0] = name_char_pair[0]; byte_string[1] = name_char_pair[1]; @@ -55,18 +55,18 @@ namespace ams::ncm { return ResultSuccess(); } - std::optional GetContentIdFromString(const char* str, size_t len) { + std::optional GetContentIdFromString(const char *str, size_t len) { if (len < 0x20) { return std::nullopt; } u8 tmp[sizeof(ContentId)] = {}; char byte_string[2]; - char* end_ptr; + char *end_ptr; u64 converted_val; for (size_t i = 0; i < sizeof(ContentId); i++) { - const char* char_par = str + i * 2; + const char *char_par = str + i * 2; byte_string[0] = char_par[0]; byte_string[1] = char_par[1]; diff --git a/stratosphere/ncm/source/ncm_utils.hpp b/stratosphere/ncm/source/ncm_utils.hpp index e2e18ed0a..b3b52a017 100644 --- a/stratosphere/ncm/source/ncm_utils.hpp +++ b/stratosphere/ncm/source/ncm_utils.hpp @@ -21,10 +21,10 @@ namespace ams::ncm { - void GetStringFromContentId(char* out, ContentId content_id); - void GetStringFromPlaceHolderId(char* out, PlaceHolderId placeholder_id); + void GetStringFromContentId(char *out, ContentId content_id); + void GetStringFromPlaceHolderId(char *out, PlaceHolderId placeholder_id); - Result GetPlaceHolderIdFromDirEntry(PlaceHolderId* out, struct dirent* dir_entry); - std::optional GetContentIdFromString(const char* str, size_t len); + Result GetPlaceHolderIdFromDirEntry(PlaceHolderId *out, struct dirent *dir_entry); + std::optional GetContentIdFromString(const char *str, size_t len); };