summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/FileBackedFileSystem.h
blob: 95cfc42337bea2feb44e8a79793b730a1f3d5b3d (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
/*
 * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/FileSystem/OpenFileDescription.h>

namespace Kernel {

class FileBackedFileSystem : public FileSystem {
public:
    virtual ~FileBackedFileSystem() override;

    File& file() { return m_file_description->file(); }
    OpenFileDescription& file_description() { return *m_file_description; }
    const File& file() const { return m_file_description->file(); }
    OpenFileDescription& file_description() const { return *m_file_description; }

protected:
    explicit FileBackedFileSystem(OpenFileDescription&);

private:
    virtual bool is_file_backed() const override { return true; }

    mutable NonnullRefPtr<OpenFileDescription> m_file_description;
};

}