summaryrefslogtreecommitdiffhomepage
path: root/dev/zka/src/NeFS+FileMgr.cxx
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-10-13 15:29:55 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-10-13 15:29:55 +0200
commit7477a0f942c374b652da4f80cdb36d4661aac3c8 (patch)
treed06627de4689b5661f4b95c4fa15f932b004ad13 /dev/zka/src/NeFS+FileMgr.cxx
parent182f2baa4d38a286d3453cc0da90ebec5fb25266 (diff)
IMP: Delete the memory list when exiting process.
IMP: Add Allocation (and delete) of MemoryList. IMP: BitMap allocator must now allocate directories as well. IMP: Add Handover arch to check if executable is an AMD64 executable or ARM64 executable. FIX: Add ::EFI::Stop, when a thread doesn't load correctly. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/zka/src/NeFS+FileMgr.cxx')
-rw-r--r--dev/zka/src/NeFS+FileMgr.cxx138
1 files changed, 138 insertions, 0 deletions
diff --git a/dev/zka/src/NeFS+FileMgr.cxx b/dev/zka/src/NeFS+FileMgr.cxx
index fa14aaae..cee80531 100644
--- a/dev/zka/src/NeFS+FileMgr.cxx
+++ b/dev/zka/src/NeFS+FileMgr.cxx
@@ -14,6 +14,7 @@
namespace Kernel
{
+#ifdef __FSKIT_USE_NEFS__
/// @brief C++ constructor
NeFileSystemMgr::NeFileSystemMgr()
{
@@ -105,6 +106,143 @@ namespace Kernel
{
return kNeFSMetaFilePrefix;
}
+
+ /// @brief Opens a new file.
+ /// @param path
+ /// @param r
+ /// @return
+ _Output NodePtr NeFileSystemMgr::Open(_Input const Char* path, _Input const Char* r)
+ {
+ if (!path || *path == 0)
+ return nullptr;
+
+ if (!r || *r == 0)
+ return nullptr;
+
+ auto catalog = fImpl->GetCatalog(path);
+
+ return node_cast(catalog);
+ }
+
+ /// @brief Writes to a catalog's fork.
+ /// @param node the node ptr.
+ /// @param data the data.
+ /// @param flags the size.
+ /// @return
+ Void NeFileSystemMgr::Write(_Input NodePtr node, _Input VoidPtr data, _Input Int32 flags, _Input SizeT size)
+ {
+ if (!node)
+ return;
+ if (!size)
+ return;
+
+ constexpr auto cDataForkName = kNeFSDataFork;
+ this->Write(cDataForkName, node, data, flags, size);
+ }
+
+ /// @brief Read from filesystem fork.
+ /// @param node the catalog node.
+ /// @param flags the flags with it.
+ /// @param sz the size to read.
+ /// @return
+ _Output VoidPtr NeFileSystemMgr::Read(_Input NodePtr node, _Input Int32 flags, _Input SizeT size)
+ {
+ if (!node)
+ return nullptr;
+ if (!size)
+ return nullptr;
+
+ constexpr auto cDataForkName = kNeFSDataFork;
+ return this->Read(cDataForkName, node, flags, size);
+ }
+
+ Void NeFileSystemMgr::Write(_Input const Char* name,
+ _Input NodePtr node,
+ _Input VoidPtr data,
+ _Input Int32 flags,
+ _Input SizeT size)
+ {
+ if (!size ||
+ size > kNeFSForkSize)
+ return;
+
+ if (!data)
+ return;
+
+ ZKA_UNUSED(flags);
+
+ if ((reinterpret_cast<NFS_CATALOG_STRUCT*>(node))->Kind == kNeFSCatalogKindFile)
+ fImpl->WriteCatalog(reinterpret_cast<NFS_CATALOG_STRUCT*>(node), (flags & cFileFlagRsrc ? true : false), data, size,
+ name);
+ }
+
+ _Output VoidPtr NeFileSystemMgr::Read(_Input const Char* name,
+ _Input NodePtr node,
+ _Input Int32 flags,
+ _Input SizeT sz)
+ {
+ if (sz > kNeFSForkSize)
+ return nullptr;
+
+ if (!sz)
+ return nullptr;
+
+ ZKA_UNUSED(flags);
+
+ if ((reinterpret_cast<NFS_CATALOG_STRUCT*>(node))->Kind == kNeFSCatalogKindFile)
+ return fImpl->ReadCatalog(reinterpret_cast<NFS_CATALOG_STRUCT*>(node), (flags & cFileFlagRsrc ? true : false), sz,
+ name);
+
+ return nullptr;
+ }
+
+ /// @brief Seek from Catalog.
+ /// @param node
+ /// @param off
+ /// @retval true always returns false, this is unimplemented.
+ /// @retval false always returns this, it is unimplemented.
+
+ _Output Bool NeFileSystemMgr::Seek(NodePtr node, SizeT off)
+ {
+ if (!node || off == 0)
+ return false;
+
+ return fImpl->Seek(reinterpret_cast<NFS_CATALOG_STRUCT*>(node), off);
+ }
+
+ /// @brief Tell where the catalog is.
+ /// @param node
+ /// @retval true always returns false, this is unimplemented.
+ /// @retval false always returns this, it is unimplemented.
+
+ _Output SizeT NeFileSystemMgr::Tell(NodePtr node)
+ {
+ if (!node)
+ return kNPos;
+
+ return fImpl->Tell(reinterpret_cast<NFS_CATALOG_STRUCT*>(node));
+ }
+
+ /// @brief Rewinds the catalog.
+ /// @param node
+ /// @retval true always returns false, this is unimplemented.
+ /// @retval false always returns this, it is unimplemented.
+
+ _Output Bool NeFileSystemMgr::Rewind(NodePtr node)
+ {
+ if (!node)
+ return false;
+
+ return this->Seek(node, 0);
+ }
+
+ /// @brief Returns the filesystem parser.
+ /// @return the Filesystem parser class.
+ _Output NeFSParser* NeFileSystemMgr::GetParser() noexcept
+ {
+ return fImpl;
+ }
+#endif // __FSKIT_USE_NEFS__
} // namespace Kernel
#endif // ifdef __FSKIT_USE_NEFS__