~aleteoryx/muditaos

ref: ae6d19ff1e4f605ec1dd6279707ab85c4e7a5766 muditaos/module-vfs/paths/filesystem_paths.cpp -rw-r--r-- 3.3 KiB
ae6d19ff — Bartosz [MOS-786] Add to docker required libraries 3 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <purefs/filesystem_paths.hpp>
#include <hal/boot_control.h>

namespace
{
    constexpr inline auto PATH_SYSTEM       = "/system";
    constexpr inline auto PATH_USER         = "/user";
    constexpr inline auto PATH_CONF         = "/mfgconf";
    constexpr inline auto PATH_DB           = "db";
    constexpr inline auto PATH_UPDATE       = "update";
    constexpr inline auto PATH_SYNC         = "sync";
    constexpr inline auto PATH_LOGS         = "log";
    constexpr inline auto PATH_CRASH_DUMPS  = "crash_dumps";
    constexpr inline auto PATH_USER_MEDIA =
        "media"; // TODO this won't work with our current non-hierarchical MTP implementation
    constexpr inline auto PATH_TMP    = "tmp";
    constexpr inline auto PATH_BACKUP = "backup";
    constexpr inline auto PATH_ASSETS  = "assets";
    constexpr inline auto PATH_DATA    = "data";
} // 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 getSystemDiskPath() noexcept
        {
            return std::filesystem::path{PATH_SYSTEM};
        }

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

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

        std::filesystem::path getDatabasesPath() noexcept
        {
            return getSystemDiskPath() / PATH_DB;
        }

        std::filesystem::path getUpdateDirPath() noexcept
        {
            return getUserDiskPath() / PATH_UPDATE;
        }

        std::filesystem::path getSyncPackagePath() noexcept
        {
            return getUserDiskPath() / PATH_SYNC; // TODO what's this?
        }

        std::filesystem::path getLogsPath() noexcept
        {
            return getSystemDiskPath() / PATH_LOGS;
        }

        std::filesystem::path getCrashDumpsPath() noexcept
        {
            return getSystemDiskPath() / PATH_CRASH_DUMPS;
        }

        std::filesystem::path getUserMediaPath() noexcept
        {
            return getUserDiskPath() / PATH_USER_MEDIA;
        }

        std::filesystem::path getTemporaryPath() noexcept
        {
            return getSystemDiskPath() / PATH_TMP; // TODO is it needed + if it is, where it should be placed
        }

        std::filesystem::path getBackupOSPath() noexcept
        {
            return getUserDiskPath() / PATH_BACKUP; // TODO is it still needed?
        }

        std::filesystem::path getBootJSONPath() noexcept
        {
            return getUserDiskPath() / file::boot_json;
        }

        std::filesystem::path getAssetsDirPath() noexcept
        {
            return getSystemDiskPath() / PATH_ASSETS;
        }

        std::filesystem::path getSystemDataDirPath() noexcept
        {
            return getSystemDiskPath() / PATH_DATA;
        }

        std::filesystem::path getUserDataDirPath() noexcept
        {
            return getUserDiskPath() / PATH_DATA;
        }
    } // namespace dir
} // namespace purefs