Table of Contents

Class CecalVirtualFileSystem

Namespace
PopcorningGuineaPig.Engine.Assets.Cecal
Assembly
PopcorningGuineaPig.Engine.dll

Memory-mapped runtime reader for .cecal archives. Loads the table of contents into an in-memory dictionary for O(1) lookup and serves asset bytes from an MemoryMappedFile view so reads cost zero heap allocation beyond the destination buffer.

public sealed class CecalVirtualFileSystem : IVirtualFileSystem, IDisposable
Inheritance
CecalVirtualFileSystem
Implements
Inherited Members

Remarks

This is the runtime counterpart to CecalReader, which is kept as a plain-FileStream reader for tooling tests. Both honor the same on-disk layout defined in PopcorningGuineaPig.Engine.Assets.Cecal.CecalFormat.

Constructors

CecalVirtualFileSystem(string)

public CecalVirtualFileSystem(string cecalPath)

Parameters

cecalPath string

Properties

EntryCount

public int EntryCount { get; }

Property Value

int

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Exists(string)

Returns true if logicalPath can be resolved by this VFS. Does not open the asset; use TryOpen(string, out Stream) for that.

public bool Exists(string logicalPath)

Parameters

logicalPath string

Returns

bool

ResolveDirectoryToTemp(string)

Extracts all entries whose logical path starts with the given directory prefix to temp files, preserving relative directory structure. Required for formats like GLTF that reference companion files (.bin, textures) via relative URIs. No-op for implementations that serve files directly from disk.

public void ResolveDirectoryToTemp(string directoryPrefix)

Parameters

directoryPrefix string

ResolveToTempFile(string)

Resolves the asset to an absolute filesystem path that a native loader (e.g. Raylib.LoadModel) can consume directly. Packed implementations extract to a cached temp file; loose implementations return the asset's on-disk location unchanged. Returns null on miss.

public string? ResolveToTempFile(string logicalPath)

Parameters

logicalPath string

Returns

string

Remarks

This exists because raylib-cs 7.0.1 has no LoadModelFromMemory and OwnAudioNET's FileSource accepts only a file path. Temp files are cached for the process lifetime and cleaned up on exit.

TryOpen(string, out Stream)

Opens a read-only, seekable Stream over the asset bytes. The caller owns the stream and must dispose it. Returns false on miss.

public bool TryOpen(string logicalPath, out Stream stream)

Parameters

logicalPath string
stream Stream

Returns

bool

TryReadAllBytes(string, out byte[])

Reads the entire asset into a new byte array. Returns false on miss.

public bool TryReadAllBytes(string logicalPath, out byte[] bytes)

Parameters

logicalPath string
bytes byte[]

Returns

bool

TryReadAllText(string, out string)

Reads the entire asset as UTF-8 text. Returns false on miss.

public bool TryReadAllText(string logicalPath, out string text)

Parameters

logicalPath string
text string

Returns

bool