Pulp
1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
special_dir.hpp
Go to the documentation of this file.
1
#pragma once
2
48
49
#include <array>
50
#include <filesystem>
51
#include <functional>
52
#include <optional>
53
#include <string>
54
#include <string_view>
55
56
namespace
pulp::platform
{
57
58
enum class
SpecialDir
{
59
home
,
60
documents
,
61
desktop
,
62
music
,
63
app_data
,
64
app_data_shared
,
65
config
,
66
temp
,
67
cache
,
68
logs
,
69
current_executable
,
70
bundle_dir
,
71
user_presets
,
72
};
73
74
inline
constexpr
std::array<SpecialDir, 13>
kAllSpecialDirs
= {
75
SpecialDir::home
,
76
SpecialDir::documents
,
77
SpecialDir::desktop
,
78
SpecialDir::music
,
79
SpecialDir::app_data
,
80
SpecialDir::app_data_shared
,
81
SpecialDir::config
,
82
SpecialDir::temp
,
83
SpecialDir::cache
,
84
SpecialDir::logs
,
85
SpecialDir::current_executable
,
86
SpecialDir::bundle_dir
,
87
SpecialDir::user_presets
,
88
};
89
91
std::string_view
special_dir_name
(
SpecialDir
kind)
noexcept
;
92
94
std::filesystem::path
special_dir
(
SpecialDir
kind);
95
99
void
set_special_dir_override
(
SpecialDir
kind, std::filesystem::path path);
100
void
clear_special_dir_overrides
();
101
102
// ── Pure resolver ───────────────────────────────────────────────────────────
103
106
enum class
SpecialDirOs
{
macos
,
ios
,
windows
,
linux_desktop
,
android
,
web
};
107
109
SpecialDirOs
host_special_dir_os
() noexcept;
110
114
struct
SpecialDirInputs
{
116
std::function<std::optional<std::string>(std::string_view)>
getenv
;
117
std::string
executable
;
118
std::string
module
;
119
std::string
known_documents
;
120
std::string
known_desktop
;
121
std::string
known_music
;
122
std::string
android_files_dir
;
123
std::string
android_cache_dir
;
124
};
125
127
std::string
special_dir_for
(
SpecialDirOs
os,
SpecialDir
kind,
const
SpecialDirInputs
& inputs);
128
129
}
// namespace pulp::platform
pulp::music
Definition
chord.hpp:14
pulp::platform
Device capability vocabulary: one tier ladder, one thermal ladder, and the projection from observed i...
Definition
child_process.hpp:15
pulp::platform::SpecialDir
SpecialDir
Definition
special_dir.hpp:58
pulp::platform::SpecialDir::cache
@ cache
Definition
special_dir.hpp:67
pulp::platform::SpecialDir::home
@ home
Definition
special_dir.hpp:59
pulp::platform::SpecialDir::music
@ music
Definition
special_dir.hpp:62
pulp::platform::SpecialDir::current_executable
@ current_executable
Definition
special_dir.hpp:69
pulp::platform::SpecialDir::logs
@ logs
Definition
special_dir.hpp:68
pulp::platform::SpecialDir::documents
@ documents
Definition
special_dir.hpp:60
pulp::platform::SpecialDir::config
@ config
Per-user settings root (an XDG distinction; equals app_data off Linux).
Definition
special_dir.hpp:65
pulp::platform::SpecialDir::temp
@ temp
Definition
special_dir.hpp:66
pulp::platform::SpecialDir::app_data_shared
@ app_data_shared
Application data shared by every user of the machine.
Definition
special_dir.hpp:64
pulp::platform::SpecialDir::app_data
@ app_data
Per-user application data.
Definition
special_dir.hpp:63
pulp::platform::SpecialDir::user_presets
@ user_presets
Definition
special_dir.hpp:71
pulp::platform::SpecialDir::bundle_dir
@ bundle_dir
Definition
special_dir.hpp:70
pulp::platform::SpecialDir::desktop
@ desktop
Definition
special_dir.hpp:61
pulp::platform::special_dir_name
std::string_view special_dir_name(SpecialDir kind) noexcept
Stable lower_snake_case name, for diagnostics and tests.
pulp::platform::set_special_dir_override
void set_special_dir_override(SpecialDir kind, std::filesystem::path path)
Replace the resolved location for kind (a mobile host that learns its sandbox paths late,...
pulp::platform::kAllSpecialDirs
constexpr std::array< SpecialDir, 13 > kAllSpecialDirs
Definition
special_dir.hpp:74
pulp::platform::SpecialDirOs
SpecialDirOs
Operating system a path is shaped for.
Definition
special_dir.hpp:106
pulp::platform::SpecialDirOs::windows
@ windows
Definition
special_dir.hpp:106
pulp::platform::SpecialDirOs::web
@ web
Definition
special_dir.hpp:106
pulp::platform::SpecialDirOs::macos
@ macos
Definition
special_dir.hpp:106
pulp::platform::SpecialDirOs::ios
@ ios
Definition
special_dir.hpp:106
pulp::platform::SpecialDirOs::android
@ android
Definition
special_dir.hpp:106
pulp::platform::SpecialDirOs::linux_desktop
@ linux_desktop
Definition
special_dir.hpp:106
pulp::platform::host_special_dir_os
SpecialDirOs host_special_dir_os() noexcept
The host OS this binary was built for.
pulp::platform::special_dir_for
std::string special_dir_for(SpecialDirOs os, SpecialDir kind, const SpecialDirInputs &inputs)
Resolve kind for os from inputs alone. Empty string when unavailable.
pulp::platform::clear_special_dir_overrides
void clear_special_dir_overrides()
pulp::platform::special_dir
std::filesystem::path special_dir(SpecialDir kind)
Resolve kind for the running process. Empty when unavailable.
pulp::platform::SpecialDirInputs
Everything the resolver may read, so every platform's layout can be computed (and tested) on any host...
Definition
special_dir.hpp:114
pulp::platform::SpecialDirInputs::known_desktop
std::string known_desktop
Definition
special_dir.hpp:120
pulp::platform::SpecialDirInputs::getenv
std::function< std::optional< std::string >(std::string_view)> getenv
Environment lookup; an unset or empty variable returns nullopt/empty.
Definition
special_dir.hpp:116
pulp::platform::SpecialDirInputs::known_documents
std::string known_documents
Windows known-folder overrides, else derived.
Definition
special_dir.hpp:119
pulp::platform::SpecialDirInputs::executable
std::string executable
Absolute path of the running executable.
Definition
special_dir.hpp:117
pulp::platform::SpecialDirInputs::known_music
std::string known_music
Definition
special_dir.hpp:121
pulp::platform::SpecialDirInputs::android_cache_dir
std::string android_cache_dir
Optional; defaults to <files>/cache.
Definition
special_dir.hpp:123
pulp::platform::SpecialDirInputs::module
std::string module
Absolute path of the binary holding this code.
Definition
special_dir.hpp:118
pulp::platform::SpecialDirInputs::android_files_dir
std::string android_files_dir
From the app-data-dir hook.
Definition
special_dir.hpp:122
core
platform
include
pulp
platform
special_dir.hpp
Generated by
1.15.0