diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-06 09:14:11 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-06 09:14:11 +0100 |
| commit | 5339d016c07bf717ee388f4feb73544087324af0 (patch) | |
| tree | 94be6f67ed626091f24aee24ec3b3be03d01e4e7 /Source/DriveManager.cxx | |
git: port from mercurial repo.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Source/DriveManager.cxx')
| -rw-r--r-- | Source/DriveManager.cxx | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Source/DriveManager.cxx b/Source/DriveManager.cxx new file mode 100644 index 00000000..4c924b75 --- /dev/null +++ b/Source/DriveManager.cxx @@ -0,0 +1,61 @@ +/* + * ======================================================== + * + * hCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <FSKit/NewFS.hxx> +#include <NewKit/Utils.hpp> + +#include <KernelKit/DebugOutput.hpp> +#include <KernelKit/DriveManager.hpp> + +namespace hCore +{ + DriveSelector::DriveSelector() : fDrive(nullptr) {} + + DriveSelector::~DriveSelector() + { + if (fDrive) + { + this->Unmount(); + } + } + + DriveTraits& DriveSelector::GetMounted() { MUST_PASS(fDrive != nullptr); return *fDrive; } + + bool DriveSelector::Mount(DriveTraits* drive) + { + if (drive && + drive->fReady() && + fDrive == nullptr) + { + fDrive = drive; + fDrive->fMount(); + + kcout << "[Mount] Mount drive: " << fDrive->fName << "\n"; + + return true; + } + + return false; + } + + DriveTraits* DriveSelector::Unmount() + { + if (!fDrive) + return nullptr; + + auto drivePointer = fDrive; + + fDrive->fUnmount(); + fDrive = nullptr; + + kcout << "[Unmount] Mount drive: " << drivePointer->fName << "\n"; + + return drivePointer; + } +} // namespace hCore |
