ncm: Updated ListContentId for 11.0.0

This commit is contained in:
Adubbz
2021-03-20 20:54:44 +11:00
committed by SciresM
parent c99ce36d7d
commit 5666c59657
2 changed files with 200 additions and 31 deletions

View File

@@ -22,16 +22,45 @@
namespace ams::ncm {
class ContentStorageImpl : public ContentStorageImplBase {
private:
class ContentIterator {
NON_COPYABLE(ContentIterator);
NON_MOVEABLE(ContentIterator);
static constexpr size_t MaxDirectoryHandles = 0x8;
static constexpr size_t MaxDirectoryEntries = 0x10;
public:
fs::DirectoryHandle handles[MaxDirectoryHandles]{};
size_t depth{};
size_t max_depth{};
PathString path{};
fs::DirectoryEntry entries[MaxDirectoryEntries]{};
s64 entry_count{};
public:
constexpr ContentIterator() = default;
~ContentIterator();
Result Initialize(const char *root_path, size_t max_depth);
Result GetNext(std::optional<fs::DirectoryEntry> *out);
private:
Result OpenCurrentDirectory();
Result OpenDirectory(const char *dir);
Result LoadEntries();
};
protected:
PlaceHolderAccessor placeholder_accessor;
ContentId cached_content_id;
fs::FileHandle cached_file_handle;
RightsIdCache *rights_id_cache;
std::optional<ContentIterator> content_iterator;
std::optional<s32> last_content_offset;
public:
static Result InitializeBase(const char *root_path);
static Result CleanupBase(const char *root_path);
static Result VerifyBase(const char *root_path);
public:
ContentStorageImpl() : rights_id_cache(nullptr), content_iterator(std::nullopt), last_content_offset(std::nullopt) { /* ... */ }
~ContentStorageImpl();
Result Initialize(const char *root_path, MakeContentPathFunction content_path_func, MakePlaceHolderPathFunction placeholder_path_func, bool delay_flush, RightsIdCache *rights_id_cache);