diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-12-26 21:49:37 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-12-26 21:49:53 +0100 |
| commit | bce9420fb8dd066188900d44248453a11a3d08d5 (patch) | |
| tree | cf78600e017480da5a4c95bf8fc8dda68c1c64e0 /dev/Kernel/KernelKit/FileMgr.h | |
| parent | 486425ed00acec134f8799bdde64bfd093c5fb55 (diff) | |
META: Overall improvements and fixes to ZkaOS.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/KernelKit/FileMgr.h')
| -rw-r--r-- | dev/Kernel/KernelKit/FileMgr.h | 50 |
1 files changed, 7 insertions, 43 deletions
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<Int64> WriteAll(const VoidPtr data) noexcept + ErrorOr<Int64> 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<Int64>(0); } return ErrorOr<Int64>(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<Int64> WriteAll(const Char* fName, const VoidPtr data) noexcept + ErrorOr<Int64> 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<Int64>(0); } return ErrorOr<Int64>(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. |
