summaryrefslogtreecommitdiffhomepage
path: root/NewKernel/Source/NewFS+FileManager.cxx
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-08 12:32:41 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-08 12:32:41 +0200
commit09dd11ddf800898c00ecb04a65fb5cd10fb481fa (patch)
treeeda0b4e23d6a71da7de3a78f0bb76ec3201dd2f9 /NewKernel/Source/NewFS+FileManager.cxx
parentca83108fd138cc0398f900e6a6c0a53ad51aee31 (diff)
MHR-23: :boom: changes, reworked project tree.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'NewKernel/Source/NewFS+FileManager.cxx')
-rw-r--r--NewKernel/Source/NewFS+FileManager.cxx89
1 files changed, 89 insertions, 0 deletions
diff --git a/NewKernel/Source/NewFS+FileManager.cxx b/NewKernel/Source/NewFS+FileManager.cxx
new file mode 100644
index 00000000..1e63d33c
--- /dev/null
+++ b/NewKernel/Source/NewFS+FileManager.cxx
@@ -0,0 +1,89 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <KernelKit/FileManager.hpp>
+#include <KernelKit/KernelHeap.hpp>
+
+#ifdef __FSKIT_NEWFS__
+
+/// @brief NewFS File manager.
+/// BUGS: 0
+
+namespace NewOS
+{
+ /// @brief C++ constructor
+ NewFilesystemManager::NewFilesystemManager()
+ {
+ MUST_PASS(Detail::fs_init_newfs());
+ fImpl = new NewFSParser();
+ }
+
+ NewFilesystemManager::~NewFilesystemManager()
+ {
+ if (fImpl)
+ {
+ delete fImpl;
+ }
+ }
+
+ /// @brief Removes a node from the filesystem.
+ /// @param fileName The filename
+ /// @return If it was deleted or not.
+ bool NewFilesystemManager::Remove(const char* fileName)
+ {
+ if (fileName == nullptr || *fileName == 0)
+ return false;
+
+ return fImpl->RemoveCatalog(fileName);
+ }
+
+ /// @brief Creates a node with the specified.
+ /// @param path The filename path.
+ /// @return The Node pointer.
+ NodePtr NewFilesystemManager::Create(const char* path)
+ {
+ return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindFile));
+ }
+
+ /// @brief Creates a node with is a directory.
+ /// @param path The filename path.
+ /// @return The Node pointer.
+ NodePtr NewFilesystemManager::CreateDirectory(const char* path)
+ {
+ return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindDir));
+ }
+
+ /// @brief Creates a node with is a alias.
+ /// @param path The filename path.
+ /// @return The Node pointer.
+ NodePtr NewFilesystemManager::CreateAlias(const char* path)
+ {
+ return node_cast(fImpl->CreateCatalog(path, 0, kNewFSCatalogKindAlias));
+ }
+
+ /// @brief Gets the root directory.
+ /// @return
+ const char* NewFilesystemHelper::Root()
+ {
+ return kNewFSRoot;
+ }
+
+ /// @brief Gets the up-dir directory.
+ /// @return
+ const char* NewFilesystemHelper::UpDir()
+ {
+ return kNewFSUpDir;
+ }
+
+ /// @brief Gets the separator character.
+ /// @return
+ const char NewFilesystemHelper::Separator()
+ {
+ return kNewFSSeparator;
+ }
+} // namespace NewOS
+
+#endif // ifdef __FSKIT_NEWFS__