22 static constexpr std::string_view assets_alias =
"assets";
23 static constexpr std::string_view shared_alias =
"shared";
27 std::string workspace =
"pixelbullet";
28 std::filesystem::path asset_base_path;
29 std::filesystem::path workspace_root;
30 std::filesystem::path packaged_runtime_root;
34 explicit Filesystem(
Config config);
35 ~Filesystem() =
default;
37 Filesystem(
const Filesystem&) =
delete;
38 Filesystem& operator=(
const Filesystem&) =
delete;
39 Filesystem(Filesystem&&) =
delete;
40 Filesystem& operator=(Filesystem&&) =
delete;
42 [[nodiscard]] std::optional<std::filesystem::path> try_resolve(
const VirtualPath& path)
const;
43 [[nodiscard]] std::optional<std::filesystem::path> try_resolve(
const AssetPath& path)
const;
44 [[nodiscard]] std::filesystem::path resolve(
const VirtualPath& path)
const;
45 [[nodiscard]] std::filesystem::path resolve(
const AssetPath& path)
const;
46 [[nodiscard]] std::filesystem::path resolve_writable(
const VirtualPath& path)
const;
47 [[nodiscard]] std::filesystem::path resolve_writable(
const AssetPath& path)
const;
48 [[nodiscard]]
bool exists(
const VirtualPath& path)
const;
49 [[nodiscard]]
bool exists(
const AssetPath& path)
const;
51 [[nodiscard]]
const std::filesystem::path& asset_base_path() const noexcept
53 return asset_base_path_;
56 [[nodiscard]]
const std::filesystem::path& workspace_root() const noexcept
58 return workspace_root_;
61 [[nodiscard]]
const std::filesystem::path& packaged_runtime_root() const noexcept
63 return packaged_runtime_root_;
67 using RuntimeLookup = std::function<std::optional<std::filesystem::path>(
const std::filesystem::path&)>;
68 friend class filesystem_internal::FilesystemRuntimeAccess;
70 explicit Filesystem(
Config config, RuntimeLookup runtime_lookup);
72 enum class VirtualRoot
81 std::filesystem::path path;
82 VirtualRoot root = VirtualRoot::Direct;
85 [[nodiscard]] std::optional<ExpandedPath> expand_path(
const VirtualPath& path)
const;
86 [[nodiscard]] std::filesystem::path build_runtime_relative_path(
const std::filesystem::path& logical_path, VirtualRoot root)
const;
87 [[nodiscard]] std::filesystem::path build_runtime_lookup_path(
const std::filesystem::path& logical_path, VirtualRoot root)
const;
88 [[nodiscard]] std::filesystem::path build_packaged_lookup(
const std::filesystem::path& logical_path, VirtualRoot root)
const;
89 [[nodiscard]]
static std::filesystem::path detect_workspace_root(
const std::filesystem::path& start_path);
92 RuntimeLookup runtime_lookup_;
93 std::string workspace_name_;
94 std::filesystem::path asset_base_path_;
95 std::filesystem::path workspace_root_;
96 std::filesystem::path packaged_runtime_root_;