From 0c11d9e2944534b2cf2aadb9a22e8892e85e8b58 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Thu, 2 Jun 2022 00:01:09 +0100 Subject: [PATCH] Implement IDirectory::GetEntryCount --- app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp | 9 ++++++++- app/src/main/cpp/skyline/services/fssrv/IDirectory.h | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp b/app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp index 0a7c50fe..37a05e6e 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp +++ b/app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp @@ -40,7 +40,14 @@ namespace skyline::service::fssrv { span(outputEntries[i].name).copy_from(entry.name); } + remainingReadCount += i; response.Push(i); return {}; } -} + + Result IDirectory::GetEntryCount(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + auto entries{backing->Read()}; + response.Push(entries.size() - remainingReadCount); + return {}; + } +} \ No newline at end of file diff --git a/app/src/main/cpp/skyline/services/fssrv/IDirectory.h b/app/src/main/cpp/skyline/services/fssrv/IDirectory.h index e98305ac..ef342baa 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IDirectory.h +++ b/app/src/main/cpp/skyline/services/fssrv/IDirectory.h @@ -17,6 +17,7 @@ namespace skyline::service::fssrv { private: std::shared_ptr backing; //!< Backing directory of the IDirectory std::shared_ptr backingFs; //!< Backing filesystem of the IDirectory + u32 remainingReadCount{}; public: IDirectory(std::shared_ptr backing, std::shared_ptr backingFs, const DeviceState &state, ServiceManager &manager); @@ -26,8 +27,14 @@ namespace skyline::service::fssrv { */ Result Read(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + /** + * @url https://switchbrew.org/wiki/Filesystem_services#GetEntryCount + */ + Result GetEntryCount(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + SERVICE_DECL( SFUNC(0x0, IDirectory, Read), + SFUNC(0x1, IDirectory, GetEntryCount) ) }; }