mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 09:45:08 +00:00

That code used the old AK::Result container, which leads to overly complicated initialization flow when trying to figure out the correct partition table type. Instead, when using the ErrorOr container the code is much simpler and more understandable.
33 lines
829 B
C++
33 lines
829 B
C++
/*
|
|
* Copyright (c) 2020-2022, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/RefPtr.h>
|
|
#include <AK/Vector.h>
|
|
#include <Kernel/Storage/Partition/DiskPartition.h>
|
|
#include <Kernel/Storage/Partition/DiskPartitionMetadata.h>
|
|
#include <Kernel/Storage/StorageDevice.h>
|
|
|
|
namespace Kernel {
|
|
|
|
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(StorageDevice const&);
|
|
|
|
NonnullRefPtr<StorageDevice> m_device;
|
|
Vector<DiskPartitionMetadata> m_partitions;
|
|
};
|
|
|
|
}
|