diff options
| author | Zach Hilman <zachhilman@gmail.com> | 2019-04-16 14:32:18 -0400 |
|---|---|---|
| committer | Zach Hilman <zachhilman@gmail.com> | 2019-09-21 16:43:10 -0400 |
| commit | 43af31836ebe923f0bd34d85b74788e78d04b4e2 (patch) | |
| tree | 84b0e1b488a80ef04181ff0892a566da72f1d6a9 /src/core/hle/service/filesystem/fsp_srv.cpp | |
| parent | 721a92775d2da30843fc5e1d9887e55dafa0bc3a (diff) | |
filesystem: Pass Size Getter functions to IFileSystem for sizes
Diffstat (limited to 'src/core/hle/service/filesystem/fsp_srv.cpp')
| -rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index d3cd46a9b..85f8e4a63 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -30,6 +30,18 @@ namespace Service::FileSystem { +struct SizeGetter { + std::function<u64()> free; + std::function<u64()> total; + + static SizeGetter FromStorageId(const FileSystemController& fsc, FileSys::StorageId id) { + return { + [&fsc, id] { return fsc.GetFreeSpaceSize(id); }, + [&fsc, id] { return fsc.GetTotalSpaceSize(id); }, + }; + } +}; + enum class FileSystemType : u8 { Invalid0 = 0, Invalid1 = 1, @@ -289,8 +301,8 @@ private: class IFileSystem final : public ServiceFramework<IFileSystem> { public: - explicit IFileSystem(FileSys::VirtualDir backend) - : ServiceFramework("IFileSystem"), backend(std::move(backend)) { + explicit IFileSystem(FileSys::VirtualDir backend, SizeGetter size) + : ServiceFramework("IFileSystem"), backend(std::move(backend)), size(std::move(size)) { static const FunctionInfo functions[] = { {0, &IFileSystem::CreateFile, "CreateFile"}, {1, &IFileSystem::DeleteFile, "DeleteFile"}, @@ -467,8 +479,25 @@ public: rb.Push(RESULT_SUCCESS); } + void GetFreeSpaceSize(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_FS, "called"); + + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(RESULT_SUCCESS); + rb.Push(size.free()); + } + + void GetTotalSpaceSize(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_FS, "called"); + + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(RESULT_SUCCESS); + rb.Push(size.total()); + } + private: VfsDirectoryServiceWrapper backend; + SizeGetter size; }; class ISaveDataInfoReader final : public ServiceFramework<ISaveDataInfoReader> { |
