coastline 0.0.4
Loading...
Searching...
No Matches
paths.h File Reference
#include <expected>
#include <filesystem>
#include <functional>
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <vector>
Include dependency graph for paths.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  coastline::GamePaths
 The directories the game reads and writes, each ending in the application directory. More...

Namespaces

namespace  coastline

Typedefs

using coastline::EnvironmentReader = std::function<std::optional<std::string>(const char *name)>
 Reads an environment variable, or nothing when it is unset or empty.

Functions

std::string coastline::Utf8FromPath (const std::filesystem::path &path)
bool coastline::PortablePathsEnabled ()
std::filesystem::path coastline::PortableRoot (const std::filesystem::path &executable, const std::filesystem::path &appImage={})
 Locate portable files beside an application bundle, AppImage, or ordinary executable.
std::expected< GamePaths, std::string > coastline::ResolvePortablePaths (const GamePaths &fallback, const std::filesystem::path &executable, const std::filesystem::path &workingDirectory={})
 Prefer adjacent configuration and assets independently when portable lookup is enabled.
std::filesystem::path coastline::StorePortablePath (const std::filesystem::path &path, const std::filesystem::path &root, const std::filesystem::path &home)
 Store an input path relative to the portable directory, using '~' for external home paths.
std::filesystem::path coastline::RestorePortablePath (const std::filesystem::path &path, const std::filesystem::path &root, const std::filesystem::path &home)
 Rebuild a stored portable input path at its current executable or home location.
std::optional< GamePaths > coastline::ResolveXdgPaths (const EnvironmentReader &environment, const std::string &application)
 Resolve the directories with the XDG Base Directory variables and their defaults under the home directory.
std::optional< GamePaths > coastline::ResolveGamePaths (const std::string &application)
 Resolve the directories with the conventions of the running operating system: the XDG Base Directory variables on Linux and the BSDs, the folders of the user's library on macOS, and the roaming and local application data folders on Windows.
std::vector< std::filesystem::path > coastline::SystemDataDirectories (const std::filesystem::path &executable)
 List system data roots, including the relocated installation and platform defaults.
std::optional< std::filesystem::path > coastline::FindAssetData (const std::filesystem::path &user, std::span< const std::filesystem::path > system)
 Find usable assets in system roots first, then in the writable user data root.
bool coastline::CreateGamePaths (const GamePaths &paths)
 Create every directory of paths that does not exist.
std::optional< std::string > coastline::MigratePortablePaths (const GamePaths &source, const GamePaths &destination, bool copyOnly=false)
 Move portable assets, settings, saves, screenshots, and state to platform directories.
std::optional< std::string > coastline::MakePortablePaths (const GamePaths &source, const std::filesystem::path &directory, bool copyOnly=false)
 Export platform data as a portable installation, without copying the executable.
std::optional< std::string > coastline::MakePortableDistribution (const GamePaths &source, const std::filesystem::path &executable, const std::filesystem::path &directory, bool copyOnly=false)
 Export installed program files and platform data into a complete portable distribution.
std::optional< std::string > coastline::ResetGamePaths (const GamePaths &paths, bool factoryReset=false)
 Clear imported assets and asset caches, or all application data for a factory reset.
std::filesystem::path coastline::DefaultAssets (const std::filesystem::path &data)
 The directory the import writes the game data to, the default pack.
std::filesystem::path coastline::PackDirectory (const std::filesystem::path &data, std::string_view pack, const std::filesystem::path &fallback={})
 The directory of a pack under assets of the data directory, named after the pack.
std::optional< std::filesystem::path > coastline::PackAssets (const std::filesystem::path &data, const std::filesystem::path &cache, std::string_view pack, const std::filesystem::path &fallback={}, std::string_view region={})
 The directory the game reads its assets from with a pack selected.

Variables

constexpr std::string_view coastline::DEFAULT_PACK = "default"
 The name of the asset pack of the import, the directory assets/default.