From 88582b84a5851338618050e62bdd8b6a1753b5b7 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 31 Mar 2018 16:02:21 -0400 Subject: fsp_srv: Implement GetSize and SetSize. --- src/core/file_sys/disk_filesystem.cpp | 5 +++-- src/core/hle/service/filesystem/fsp_srv.cpp | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp index 3a4b45721..4235f3935 100644 --- a/src/core/file_sys/disk_filesystem.cpp +++ b/src/core/file_sys/disk_filesystem.cpp @@ -174,8 +174,9 @@ u64 Disk_Storage::GetSize() const { } bool Disk_Storage::SetSize(const u64 size) const { - LOG_WARNING(Service_FS, "(STUBBED) called"); - return false; + file->Resize(size); + file->Flush(); + return true; } Disk_Directory::Disk_Directory(const std::string& path) : directory() { diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index 41b8cbfd2..92b3d07b4 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -72,8 +72,8 @@ public: explicit IFile(std::unique_ptr&& backend) : ServiceFramework("IFile"), backend(std::move(backend)) { static const FunctionInfo functions[] = { - {0, &IFile::Read, "Read"}, {1, &IFile::Write, "Write"}, {2, nullptr, "Flush"}, - {3, nullptr, "SetSize"}, {4, nullptr, "GetSize"}, + {0, &IFile::Read, "Read"}, {1, &IFile::Write, "Write"}, {2, nullptr, "Flush"}, + {3, &IFile::SetSize, "SetSize"}, {4, &IFile::GetSize, "GetSize"}, }; RegisterHandlers(functions); } @@ -150,6 +150,25 @@ private: IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); } + + void SetSize(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const u64 size = rp.Pop(); + backend->SetSize(size); + LOG_DEBUG(Service_FS, "called, size=0x%ld, length=0x%ld", size); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); + } + + void GetSize(Kernel::HLERequestContext& ctx) { + const u64 size = backend->GetSize(); + LOG_DEBUG(Service_FS, "called, size=0x%ld", size); + + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(RESULT_SUCCESS); + rb.Push(size); + } }; class IDirectory final : public ServiceFramework { -- cgit v1.2.3