Engine → Assets → asset_cache.h
asset_cache
| Type | Class |
| Namespace | conjure::assets |
| Include File Path | engine/include/conjure/assets/asset_cache.h |
| Source File Path | engine/src/assets/asset_cache.cpp |
| API ↗ | Cooking, caches and packs |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | asset_cache(
core::vfs::file_system &fileSystem,
std::string_view cacheRoot,
std::string_view platform); |
Important
Copy constructor and assignment has been deleted.
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~asset_cache(); |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mBlobRoot | std::string | {} | |
| private | mFileSystem | core::vfs::file_system * | nullptr | |
| private | mPlatform | std::string | {} | |
| private | mRoot | std::string | {} |
Functions
Public
blob_path
blob_path[[nodiscard]] std::string blob_path(
const asset_id &id) const;Path of the blob of a uuid: blobs/<first two hex chars>/<uuid>.cab under the root.
contains
contains[[nodiscard]] bool contains(
const asset_id &id) const;True when a blob file exists for the uuid (not validated).
is_valid
is_valid[[nodiscard]] static bool is_valid(
const cooked_blob_header &header,
const cache_expectation &expected) noexcept;True when the header matches the expectation and the current blob format.
platform
platform[[nodiscard]] std::string_view platform() const noexcept;read
read[[nodiscard]] core::result<cooked_blob> read(
const asset_id &id) const;Reads and fully validates a blob. CACHE_MISS when absent, CACHE_CORRUPT on any validation failure (including a header that names another uuid).
read_header
read_header[[nodiscard]] core::result<cooked_blob_header> read_header(
const asset_id &id) const;Reads and validates only the header. CACHE_MISS when absent, CACHE_CORRUPT when the header is malformed or names another uuid.
remove
remove[[nodiscard]] core::result<void> remove(
const asset_id &id) const;Deletes a blob. Succeeds when there was none.
remove_temporaries
remove_temporaries[[nodiscard]] core::result<u32> remove_temporaries() const;Deletes every *.tmp left by an interrupted write. Returns how many were removed.
root
root[[nodiscard]] std::string_view root() const noexcept;vfs
vfs[[nodiscard]] core::vfs::file_system &vfs() const noexcept;write
write[[nodiscard]] core::result<void> write(
const cooked_blob &blob) const;Writes a blob through <path>.tmp + rename. IO_ERROR when the file system refuses.