~aleteoryx/muditaos

ref: 90117445f1372a9d302c5cb226510cb39c6dba21 muditaos/module-vfs/include/user/purefs/fs/file_handle.hpp -rw-r--r-- 1.3 KiB
90117445 — Przemyslaw Brudny Merge remote-tracking branch 'origin/stable' 4 years ago
                                                                                
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
42
43
44
45
46
47
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <memory>
#include <string>

namespace purefs::fs::internal
{
    class mount_point;
    // File handle used for internal operation
    class file_handle
    {
      public:
        file_handle(const file_handle &) = delete;
        auto operator=(const file_handle &) = delete;
        virtual ~file_handle()              = default;
        file_handle(std::shared_ptr<mount_point> mp, unsigned flags) : m_mount_point(mp), m_flags(flags)
        {}
        [[nodiscard]] auto error() const noexcept
        {
            return m_error;
        }
        auto error(int error) noexcept -> void
        {
            m_error = error;
        }
        [[nodiscard]] auto flags() const noexcept
        {
            return m_flags;
        }
        [[nodiscard]] auto mntpoint() const noexcept
        {
            return m_mount_point.lock();
        }
        [[nodiscard]] virtual auto open_path() const noexcept -> std::string
        {
            return {};
        }

      private:
        const std::weak_ptr<mount_point> m_mount_point;
        int m_error{};
        const unsigned m_flags{};
    };
} // namespace purefs::fs::internal