ladybird/Kernel/Storage/Partition/GUIDPartitionTable.h
Liav A 5ed3f7c6bf Kernel/Storage: Migrate the partition code to use the ErrorOr container
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.
2022-04-28 22:13:54 +02:00

38 lines
872 B
C++

/*
* Copyright (c) 2020-2022, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Error.h>
#include <AK/RefPtr.h>
#include <AK/Result.h>
#include <AK/Types.h>
#include <AK/Vector.h>
#include <Kernel/Storage/Partition/MBRPartitionTable.h>
namespace Kernel {
struct GUIDPartitionHeader;
class GUIDPartitionTable final : public MBRPartitionTable {
public:
virtual ~GUIDPartitionTable() = default;
;
static ErrorOr<NonnullOwnPtr<GUIDPartitionTable>> try_to_initialize(StorageDevice const&);
explicit GUIDPartitionTable(StorageDevice const&);
virtual bool is_valid() const override { return m_valid; };
private:
bool is_unused_entry(Array<u8, 16>) const;
GUIDPartitionHeader const& header() const;
bool initialize();
bool m_valid { true };
ByteBuffer m_cached_header;
};
}