diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-04-30 08:15:54 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-04-30 08:15:54 +0200 |
| commit | f86125cf437fb49587d588413d69646959a58541 (patch) | |
| tree | 045a19e28860280a29bb8fc218a6909343691878 /Private/Source/AppMain.cxx | |
| parent | 77423c4fa55a060c5cf710bbe5c4de02fce43e97 (diff) | |
MHR-18: Quality assurance of the filesystem.
- File/Directory removal and creation.
- Read/Write support.
- Sanitu check and catalog validation.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/Source/AppMain.cxx')
| -rw-r--r-- | Private/Source/AppMain.cxx | 61 |
1 files changed, 21 insertions, 40 deletions
diff --git a/Private/Source/AppMain.cxx b/Private/Source/AppMain.cxx index 8fb9a4ba..966172df 100644 --- a/Private/Source/AppMain.cxx +++ b/Private/Source/AppMain.cxx @@ -26,55 +26,36 @@ EXTERN_C NewOS::Void AppMain(NewOS::Void) { NewOS::FilesystemManagerInterface::Mount(newFS); if (newFS->GetImpl()) { - NewCatalog* mountCatalog = newFS->GetImpl()->GetCatalog("/Boot/"); + NewCatalog* textCatalog = nullptr; - if (mountCatalog) { - delete newFS->GetImpl()->CreateCatalog("/Boot/System/", 0, - kNewFSCatalogKindDir); - NewCatalog* newKernelCatalog = - newFS->GetImpl()->CreateCatalog("/Boot/System/ExampleTextFile"); + if (!newFS->GetImpl()->GetCatalog("/EditableText")) { + constexpr auto cDataSz = 512; + NewOS::Char theData[cDataSz] = { + "About NewKernel...\rNewKernel is the System behind " + "NewOS.\rFeaturing modern common features, yet innovative.\r"}; - NewOS::kcout << NewOS::hex_number(newKernelCatalog->Flags) << NewOS::endl; + NewFork theFork{0}; - if (newKernelCatalog) - NewOS::kcout << "Catalog-Path-Name: " << newKernelCatalog->Name - << NewOS::endl; + NewOS::rt_copy_memory((NewOS::VoidPtr) "EditableText", + (NewOS::VoidPtr)theFork.Name, + NewOS::rt_string_len("EditableText")); - NewOS::kcout << "Catalog-Path-Name: " << mountCatalog->Name - << NewOS::endl; + theFork.Kind = NewOS::kNewFSDataForkKind; + theFork.DataSize = cDataSz; - constexpr auto cDataSz = 512; - NewOS::Char theData[cDataSz] = { - "About NewKernel...\rNewKernel is the System behind " - "NewOS.\rFeaturing modern common features, yet innovative.\r"}; + textCatalog = newFS->GetImpl()->CreateCatalog("/EditableText"); - NewFork theFork{0}; - NewOS::rt_copy_memory((NewOS::VoidPtr) "EditableText", - (NewOS::VoidPtr)theFork.Name, - NewOS::rt_string_len("EditableText")); - - theFork.Kind = NewOS::kNewFSDataForkKind; - theFork.DataSize = cDataSz; - - newFS->GetImpl()->CreateFork(newKernelCatalog, theFork); - newFS->GetImpl()->WriteCatalog(newKernelCatalog, theData, cDataSz); - - //newFS->GetImpl()->RemoveCatalog("/Boot/System/ExampleTextFile"); - - - - char* buf = nullptr; + newFS->GetImpl()->CreateFork(textCatalog, theFork); + newFS->GetImpl()->WriteCatalog(textCatalog, theData, cDataSz); + } else { + NewOS::kcout << "Catalog already exists.\r"; + } - buf = - (NewOS::Char*)newFS->GetImpl()->ReadCatalog("/Boot/System/ExampleTextFile", 512); + char* buf = nullptr; - NewOS::kcout << buf << NewOS::endl; + buf = (NewOS::Char*)newFS->GetImpl()->ReadCatalog(newFS->GetImpl()->GetCatalog("/EditableText"), 512); - delete newKernelCatalog; - delete mountCatalog; - } else { - delete newFS->GetImpl()->CreateCatalog("/Boot/", 0, kNewFSCatalogKindDir); - } + NewOS::kcout << buf << NewOS::endl; } while (NewOS::ProcessScheduler::Shared().Leak().Run() > 0) |
