aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Asset.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-22 15:10:49 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-22 15:10:49 +0100
commitd038f192c7dcb453c9fc19082cd1b642c8f70fc8 (patch)
treebcb539657cd8b35ed742f19e5673c777ab39610c /src/crepe/api/Asset.h
parentc3c3476f1d82aa83d8f8dc706488475dc2cf1e55 (diff)
parent4117d1d287f1d87efd0577d56819520e981a7f1c (diff)
merge with `master`
Diffstat (limited to 'src/crepe/api/Asset.h')
-rw-r--r--src/crepe/api/Asset.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/crepe/api/Asset.h b/src/crepe/api/Asset.h
index 685dd3a..bfd0ac7 100644
--- a/src/crepe/api/Asset.h
+++ b/src/crepe/api/Asset.h
@@ -33,13 +33,29 @@ public:
* \param other Possibly different instance of \c Asset to test equality against
* \return True if \c this and \c other are equal
*/
- bool operator == (const Asset & other) const noexcept;
+ bool operator==(const Asset & other) const noexcept;
private:
//! path to asset
const std::string src;
private:
+ /**
+ * \brief Locate asset path, or throw exception if it cannot be found
+ *
+ * This function resolves asset locations relative to crepe::Config::root_pattern if it is
+ * set and \p src is a relative path. If \p src is an absolute path, it is canonicalized.
+ * This function only returns if the file can be found.
+ *
+ * \param src Arbitrary path to resource file
+ *
+ * \returns \p src if crepe::Config::root_pattern is empty
+ * \returns Canonical path to \p src
+ *
+ * \throws std::runtime_error if root_pattern cannot be found
+ * \throws std::filesystem::filesystem_error if the resolved path does not exist
+ * \throws std::filesystem::filesystem_error if the path cannot be canonicalized
+ */
std::string find_asset(const std::string & src) const;
/**
* \returns The path to the current executable
@@ -52,7 +68,8 @@ private:
namespace std {
//! Hash helper struct
-template<> struct hash<const crepe::Asset> {
+template <>
+struct hash<const crepe::Asset> {
/**
* \brief Hash operator for crepe::Asset
*
@@ -64,5 +81,4 @@ template<> struct hash<const crepe::Asset> {
size_t operator()(const crepe::Asset & asset) const noexcept;
};
-}
-
+} // namespace std