Skip to content

Engine → Assets → asset_cache.h

asset_cache

Syntax

class CONJURE_API asset_cache

Constructors

AccessSignatureDescription
publicasset_cache( core::vfs::file_system &fileSystem, std::string_view cacheRoot, std::string_view platform);

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~asset_cache();

Variables

AccessNameTypeDefaultDescription
privatemBlobRootstd::string{}
privatemFileSystemcore::vfs::file_system *nullptr
privatemPlatformstd::string{}
privatemRootstd::string{}

Functions

Public

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.

clear

[[nodiscard]] core::result<void> clear() const;

Deletes every blob of this platform.

contains

[[nodiscard]] bool contains(
    const asset_id &id) const;

True when a blob file exists for the uuid (not validated).

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

[[nodiscard]] std::string_view platform() const noexcept;

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

[[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

[[nodiscard]] core::result<void> remove(
    const asset_id &id) const;

Deletes a blob. Succeeds when there was none.

remove_temporaries

[[nodiscard]] core::result<u32> remove_temporaries() const;

Deletes every *.tmp left by an interrupted write. Returns how many were removed.

root

[[nodiscard]] std::string_view root() const noexcept;

vfs

[[nodiscard]] core::vfs::file_system &vfs() const noexcept;

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.