diff options
| author | amlal <amlal@el-mahrouss-logic.com> | 2024-03-21 00:38:52 +0100 |
|---|---|---|
| committer | amlal <amlal@el-mahrouss-logic.com> | 2024-03-21 00:38:52 +0100 |
| commit | 333fed96b7ccd3ee4f5f097445408dde34d330db (patch) | |
| tree | a1c9894b26bd81c2e762b5487e04601b357682f2 /Public/Kits/System.Core/File.hxx | |
| parent | f48c5b2cda43241919d3ea1b263bef01e014c537 (diff) | |
Kernel: See below.
- Fix kernel heap, made it better.
- Fix System.Core, made it better.
Signed-off-by: amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Public/Kits/System.Core/File.hxx')
| -rw-r--r-- | Public/Kits/System.Core/File.hxx | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/Public/Kits/System.Core/File.hxx b/Public/Kits/System.Core/File.hxx index 97377800..7ae70faf 100644 --- a/Public/Kits/System.Core/File.hxx +++ b/Public/Kits/System.Core/File.hxx @@ -4,39 +4,68 @@ ------------------------------------------- */ -#ifndef _SYSTEM_KIT_HCORE_FILE_HPP -#define _SYSTEM_KIT_HCORE_FILE_HPP +#ifndef __FILE_API__ +#define __FILE_API__ #include <CompilerKit/CompilerKit.hxx> #include <NewKit/Defines.hpp> -using namespace HCore; - /// @brief SOM class, translated to C++ namespace System { class File final { public: - explicit File(const char *path); - ~File(); + explicit File(const char *path) { + mHandle = kInstanceObject->Invoke(kInstanceObject, kProcessCallOpenHandle, + 0, path); + } + + ~File() { + kInstanceObject->Invoke(kInstanceObject, kProcessCallCloseHandle, 0, + mHandle); + } public: HCORE_COPY_DEFAULT(File); public: - voidPtr Read(SizeT off, SizeT sz); - void Write(VoidPtr buf, SizeT off, SizeT sz); - void Seek(SizeT off); - voidPtr Read(SizeT sz); - void Write(VoidPtr buf, SizeT sz); - void Rewind(); + voidPtr Read(UIntPtr off, SizeT sz) { return (VoidPtr)kInstanceObject->Invoke(kInstanceObject, mHandle, 2, off, sz); } + voidPtr Read(SizeT sz) { return (VoidPtr)kInstanceObject->Invoke(kInstanceObject, mHandle, 3, sz); } + + void Write(VoidPtr buf, UIntPtr off, SizeT sz) { kInstanceObject->Invoke(kInstanceObject, mHandle, 4, buf, off, sz); } + void Write(VoidPtr buf, SizeT sz) { kInstanceObject->Invoke(kInstanceObject, mHandle, 5, buf, sz); } + + void Seek(UIntPtr off) { kInstanceObject->Invoke(kInstanceObject, mHandle, 5); } + void Rewind() { kInstanceObject->Invoke(kInstanceObject, mHandle, 6); } public: const char *MIME(); void MIME(const char *mime); + + private: + IntPtr mHandle; }; typedef File *FilePtr; -} // namespace System -#endif // ifndef _SYSTEM_KIT_HCORE_FILE_HPP +/// @brief file exception +/// Throws when the file isn't found or invalid. +class FileException : public SystemException { + public: + explicit FileException() = default; + virtual ~FileException() = default; + + public: + HCORE_COPY_DEFAULT(FileException); + + public: + const char *Name() override { return "FileException"; } + const char *Reason() override { return mReason; } + + private: + const char *mReason{"System.Core: FileException: Catastrophic failure!"}; +}; + +} // namespace System + +#endif // ifndef __FILE_API__ |
