~aleteoryx/muditaos

ref: 6bd165c4d9946a30a9a2e4a3f882160fd6bf5f17 muditaos/module-vfs/src/purefs/filesystem_paths.cpp -rw-r--r-- 2.2 KiB
6bd165c4 — Marcin Smoczyński [EGD-6715] Add chapter bsp to the code owners 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <purefs/filesystem_paths.hpp>

namespace
{
    constexpr inline auto PATH_SYS      = "/sys";
    constexpr inline auto PATH_CONF     = "/mfgconf";
    constexpr inline auto PATH_USER     = "user";
    constexpr inline auto PATH_CURRENT  = "current";
    constexpr inline auto PATH_PREVIOUS = "previous";
    constexpr inline auto PATH_UPDATES  = "updates";
    constexpr inline auto PATH_TMP      = "tmp";
    constexpr inline auto PATH_BACKUP   = "backup";
    constexpr inline auto PATH_FACTORY  = "factory";
    constexpr inline auto eMMC_disk     = PATH_SYS;
} // namespace

namespace purefs
{
    std::filesystem::path createPath(const std::string &parent, const std::string &child) noexcept
    {
        return std::filesystem::path{parent} / child;
    }

    namespace dir
    {
        std::filesystem::path getRootDiskPath() noexcept
        {
            return std::filesystem::path{eMMC_disk};
        }

        std::filesystem::path getMfgConfPath() noexcept
        {
            return std::filesystem::path{PATH_CONF};
        }

        std::filesystem::path getUserDiskPath() noexcept
        {
            return std::filesystem::path{eMMC_disk} / PATH_USER;
        }

        std::filesystem::path getCurrentOSPath() noexcept
        {
            return std::filesystem::path{eMMC_disk} / PATH_CURRENT;
        }

        std::filesystem::path getPreviousOSPath() noexcept
        {
            return std::filesystem::path{eMMC_disk} / PATH_PREVIOUS;
        }

        std::filesystem::path getUpdatesOSPath() noexcept
        {
            return std::filesystem::path{eMMC_disk} / PATH_USER / PATH_UPDATES;
        }

        std::filesystem::path getTemporaryPath() noexcept
        {
            return std::filesystem::path{eMMC_disk} / PATH_USER / PATH_TMP;
        }

        std::filesystem::path getBackupOSPath() noexcept
        {
            return std::filesystem::path{eMMC_disk} / PATH_USER / PATH_BACKUP;
        }

        std::filesystem::path getFactoryOSPath() noexcept
        {
            return std::filesystem::path{eMMC_disk} / PATH_FACTORY;
        }
    } // namespace dir
} // namespace purefs