Lysa  0.0
Lysa 3D Engine
ResourcesPack Class Reference

Detailed Description

Lysa resources pack binary file format containing all resources for a game, referred by app://

┌──────────────────────────────────────┐ │ Magic : "LYPACK" (6 bytes) │ │ Version : uint32 │ │ Count : uint32 │ ├──────────────────────────────────────┤ │ Directory [Count entries] │ │ entry[i].path : char[256] │ │ entry[i].offset : uint64 │ │ entry[i].size : uint64 │ ├──────────────────────────────────────┤ │ Data blob │ │ raw resources │ └──────────────────────────────────────┘

Classes

struct  Entry
 
struct  Header
 

Public Member Functions

 ResourcesPack (const std::filesystem::path &filePath)
 
bool contains (std::string_view relativePath) const
 
void load (std::string_view relativePath, std::vector< char > &out) const
 
bool containsPrefix (std::string_view prefix) const
 
std::shared_ptr< ResourcesPackStreambufopenStream (std::string_view relativePath) const
 

Static Public Attributes

static constexpr char MAGIC [] { 'L','Y','P','A','C','K' }
 
static constexpr auto VERSION {1}
 
static constexpr size_t PATH_SIZE {256}
 

Constructor & Destructor Documentation

ResourcesPack ( const std::filesystem::path &  filePath)

Opens and parses a pack file, loading its directory into memory. Automatically done in VirtualFS from the configuration.

Member Function Documentation

bool contains ( std::string_view  relativePath) const

Checks whether the pack contains an entry for the given path.

Parameters
relativePathVirtual resource path (e.g. "shaders/pbr.vert").
Returns
true if an entry with that path exists, false otherwise.
bool containsPrefix ( std::string_view  prefix) const

Checks whether the directory contains any entry whose path starts with the given prefix.

Parameters
prefixPath prefix to search for.
Returns
true if at least one entry matches, false otherwise.
void load ( std::string_view  relativePath,
std::vector< char > &  out 
) const

Loads the raw bytes of a resource into a caller-supplied buffer.

The buffer is resized to fit the resource exactly before the data is copied into it.

std::shared_ptr<ResourcesPackStreambuf> openStream ( std::string_view  relativePath) const

Creates a streaming buffer over a resource region without loading the entire resource into memory.

The returned ResourcesPackStreambuf can be wrapped in a std::istream to enable incremental, standard-library-compatible reading.

Parameters
relativePathVirtual resource path.
Returns
A shared pointer to the streambuf; the underlying file handle is owned by this ResourcesPack instance.

Member Data Documentation

constexpr char MAGIC[] { 'L','Y','P','A','C','K' }
staticconstexpr
constexpr size_t PATH_SIZE {256}
staticconstexpr
constexpr auto VERSION {1}
staticconstexpr