summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/ISO9660FS/DirectoryEntry.h
blob: efb82f5907d1c275931059c70f8da5c6d87cc489 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * Copyright (c) 2021, sin-ack <sin-ack@protonmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Types.h>
#include <Kernel/Library/KBuffer.h>

namespace Kernel {

struct ISO9660FSDirectoryEntry final : public AtomicRefCounted<ISO9660FSDirectoryEntry> {
    u32 extent { 0 };
    u32 length { 0 };

    // NOTE: This can never be empty if we read the directory successfully.
    //       We need it as an OwnPtr to default-construct this struct.
    OwnPtr<KBuffer> blocks;

    static ErrorOr<NonnullLockRefPtr<ISO9660FSDirectoryEntry>> try_create(u32 extent, u32 length, OwnPtr<KBuffer> blocks)
    {
        return adopt_nonnull_lock_ref_or_enomem(new (nothrow) ISO9660FSDirectoryEntry(extent, length, move(blocks)));
    }

private:
    ISO9660FSDirectoryEntry(u32 extent, u32 length, OwnPtr<KBuffer> blocks)
        : extent(extent)
        , length(length)
        , blocks(move(blocks))
    {
    }
};

struct ISO9660FSDirectoryState {
    LockRefPtr<ISO9660FSDirectoryEntry> entry;
    u32 offset { 0 };
};

}