From bce9420fb8dd066188900d44248453a11a3d08d5 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 26 Dec 2024 21:49:37 +0100 Subject: META: Overall improvements and fixes to ZkaOS. Signed-off-by: Amlal El Mahrouss --- dev/Kernel/KernelKit/FileMgr.h | 50 ++++++------------------------------------ 1 file changed, 7 insertions(+), 43 deletions(-) (limited to 'dev/Kernel/KernelKit/FileMgr.h') diff --git a/dev/Kernel/KernelKit/FileMgr.h b/dev/Kernel/KernelKit/FileMgr.h index c448519e..07be1089 100644 --- a/dev/Kernel/KernelKit/FileMgr.h +++ b/dev/Kernel/KernelKit/FileMgr.h @@ -209,7 +209,7 @@ namespace Kernel FileStream(const FileStream&); public: - ErrorOr WriteAll(const VoidPtr data) noexcept + ErrorOr Write(const SizeT offset, const VoidPtr data, SizeT len) noexcept { if (this->fFileRestrict != kFileMgrRestrictReadWrite && this->fFileRestrict != kFileMgrRestrictReadWriteBinary && @@ -224,33 +224,14 @@ namespace Kernel if (man) { - man->Write(fFile, data, kFileWriteAll); + man->Write(offset, fFile, data, len); return ErrorOr(0); } return ErrorOr(kErrorInvalidData); } - VoidPtr ReadAll() noexcept - { - if (this->fFileRestrict != kFileMgrRestrictReadWrite && - this->fFileRestrict != kFileMgrRestrictReadWriteBinary && - this->fFileRestrict != kFileMgrRestrictRead && - this->fFileRestrict != kFileMgrRestrictReadBinary) - return nullptr; - - auto man = FSClass::GetMounted(); - - if (man) - { - VoidPtr ret = man->Read(fFile, kFileReadAll, 0); - return ret; - } - - return nullptr; - } - - ErrorOr WriteAll(const Char* fName, const VoidPtr data) noexcept + ErrorOr Write(const Char* name, const VoidPtr data, SizeT len) noexcept { if (this->fFileRestrict != kFileMgrRestrictReadWrite && this->fFileRestrict != kFileMgrRestrictReadWriteBinary && @@ -265,14 +246,14 @@ namespace Kernel if (man) { - man->Write(fName, fFile, data, kFileWriteAll); + man->Write(name, fFile, data, len); return ErrorOr(0); } return ErrorOr(kErrorInvalidData); } - VoidPtr Read(const Char* fName) noexcept + VoidPtr Read(const Char* name, const SizeT sz) noexcept { if (this->fFileRestrict != kFileMgrRestrictReadWrite && this->fFileRestrict != kFileMgrRestrictReadWriteBinary && @@ -284,14 +265,14 @@ namespace Kernel if (man) { - VoidPtr ret = man->Read(fName, fFile, kFileReadAll, 0); + VoidPtr ret = man->Read(name, fFile, kFileReadAll, 0); return ret; } return nullptr; } - VoidPtr Read(SizeT offset, SizeT sz) + VoidPtr Read(SizeT offset, const SizeT sz) { if (this->fFileRestrict != kFileMgrRestrictReadWrite && this->fFileRestrict != kFileMgrRestrictReadWriteBinary && @@ -312,23 +293,6 @@ namespace Kernel return nullptr; } - Void Write(SizeT offset, voidPtr data, SizeT sz) - { - if (this->fFileRestrict != kFileMgrRestrictReadWrite && - this->fFileRestrict != kFileMgrRestrictReadWriteBinary && - this->fFileRestrict != kFileMgrRestrictWrite && - this->fFileRestrict != kFileMgrRestrictWriteBinary) - return; - - auto man = FSClass::GetMounted(); - - if (man) - { - man->Seek(fFile, offset); - man->Write(fFile, data, sz, kFileReadChunk); - } - } - public: /// @brief Leak node pointer. /// @return The node pointer. -- cgit v1.2.3