mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:57:44 +00:00
Kernel+LibPartition: Move PartitionTable into LibPartition
This commit is contained in:
parent
be1c5c6b9f
commit
940dde9947
8 changed files with 42 additions and 43 deletions
|
@ -1,5 +1,6 @@
|
|||
set(SOURCES
|
||||
DiskPartitionMetadata.cpp
|
||||
PartitionTable.cpp
|
||||
)
|
||||
|
||||
serenity_lib(LibPartition partition)
|
||||
|
|
23
Userland/Libraries/LibPartition/PartitionTable.cpp
Normal file
23
Userland/Libraries/LibPartition/PartitionTable.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibPartition/PartitionTable.h>
|
||||
|
||||
namespace Partition {
|
||||
|
||||
PartitionTable::PartitionTable(Kernel::StorageDevice const& device)
|
||||
: m_device(device)
|
||||
{
|
||||
}
|
||||
|
||||
Optional<DiskPartitionMetadata> PartitionTable::partition(unsigned index)
|
||||
{
|
||||
if (index > partitions_count())
|
||||
return {};
|
||||
return m_partitions[index];
|
||||
}
|
||||
|
||||
}
|
30
Userland/Libraries/LibPartition/PartitionTable.h
Normal file
30
Userland/Libraries/LibPartition/PartitionTable.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Kernel/Storage/StorageDevice.h>
|
||||
#include <LibPartition/DiskPartitionMetadata.h>
|
||||
|
||||
namespace Partition {
|
||||
|
||||
class PartitionTable {
|
||||
public:
|
||||
Optional<DiskPartitionMetadata> partition(unsigned index);
|
||||
size_t partitions_count() const { return m_partitions.size(); }
|
||||
virtual ~PartitionTable() = default;
|
||||
virtual bool is_valid() const = 0;
|
||||
|
||||
Vector<DiskPartitionMetadata> partitions() const { return m_partitions; }
|
||||
|
||||
protected:
|
||||
explicit PartitionTable(Kernel::StorageDevice const&);
|
||||
|
||||
NonnullRefPtr<Kernel::StorageDevice> m_device;
|
||||
Vector<DiskPartitionMetadata> m_partitions;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue