class Bakelite::Volume

Overview

Represents an isolated virtual filesystem volume. Volumes manage their own file registry, mount prefix, priority, and default storage policies.

Defined in:

bakelite/dsl/verify_archive_builder.cr
bakelite/volume.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(name : Symbol | String, mount_point : String = "", priority : Int32 = 0, default_chunk_size : UInt32 = 65536_u32, default_compression : CompressionType = CompressionType::Deflate) #

[View source]

Class Method Detail

def self.normalize_path(path : String | Path) : String #

Normalizes directory separators to forward slashes and strips leading/trailing slashes.


[View source]

Instance Method Detail

def [](rel_path : String) : Item #

Array access alias for get.


[View source]
def []?(rel_path : String) : Item | Nil #

Nilable array access alias for get?.


[View source]
def add(item : Item) : Item #

Registers an item into this volume.


[View source]
def content_address : String #

Canonical content address URI for this volume's manifest ("sha256:").


[View source]
def content_manifest : Hash(String, String) #

Returns a deterministically sorted mapping of normalized relative file paths to SHA-256 hex digests.


[View source]
def default_chunk_size : UInt32 #

[View source]
def default_chunk_size=(default_chunk_size : UInt32) #

[View source]
def default_compression : CompressionType #

[View source]
def default_compression=(default_compression : CompressionType) #

[View source]
def each_file(&block : Item -> ) : Nil #

Iterates over all items in this volume.


[View source]
def empty? : Bool #

Checks if this volume has no files.


[View source]
def extract(destination_dir : Path | String, overwrite : Bool = true) : Int32 #

Extracts all files from this volume into destination_dir on disk.


[View source]
def extract_folder(prefix : String, destination_dir : Path | String, overwrite : Bool = true) : Int32 #

Extracts a subfolder matching prefix into destination_dir.


[View source]
def files : Array(String) #

Returns all relative virtual file paths registered in this volume.


[View source]
def files_with_prefix(prefix : String) : Array(String) #

Returns all relative paths starting with the given prefix.


[View source]
def find_all_by_sha256(digest : String) : Array(Item) #

Finds all items in this volume matching a SHA-256 content address (in deterministic path order).


[View source]
def find_by_sha256(digest : String) : Item | Nil #

Finds the first item (in deterministic lexicographical path order) matching a SHA-256 content address.


[View source]
def get(rel_path : String) : Item #

Fetches an item by relative path inside this volume. Raises KeyError if missing.


[View source]
def get?(rel_path : String) : Item | Nil #

Fetches an item by relative path inside this volume, returning nil if missing.


[View source]
def get_by_sha256(digest : String) : Item #

Fetches an item by its SHA-256 content address, raising KeyError if not found.


[View source]
def get_by_sha256?(digest : String) : Item | Nil #

Alias for find_by_sha256.


[View source]
def glob(pattern : String, & : Item -> ) : Nil #

Matches files using glob patterns (e.g. "**/.png", "textures/").


[View source]
def glob(pattern : String) : Array(Item) #

Returns an array of items matching the glob pattern.


[View source]
def has_file?(rel_path : String) : Bool #

Checks if a relative path exists in this volume.


[View source]
def has_sha256?(digest : String) : Bool #

Checks whether an item with the given SHA-256 content address exists in this volume.


[View source]
def items : Hash(String, Item) #

[View source]
def manifest_sha256 : String #

Computes a deterministic SHA-256 manifest digest over all files in this volume. Order-independent: identical files produce an identical 64-character hex digest.


[View source]
def mount_point : String #

[View source]
def mount_point=(new_mount : String) #

[View source]
def mount_prefix_with_slash : String #

[View source]
def name : String #

[View source]
def priority : Int32 #

[View source]
def priority=(priority : Int32) #

[View source]
def sha256 : String #

Alias for manifest_sha256.


[View source]
def size : Int32 #

Total number of files in this volume.


[View source]
def verify_archive(raise_on_error : Bool = false, expected_digests : Hash(String, String) | Nil = nil, expected_manifest_sha256 : String | Nil = nil, strict : Bool = false) : Core::VerificationReport #

Verifies the SHA-256 and CRC32 integrity of all items in this volume.


[View source]
def verify_archive(raise_on_error : Bool = false, &) : Core::VerificationReport #

[View source]
def verify_archive! : Core::VerificationReport #

[View source]
def verify_archive!(&) : Core::VerificationReport #

[View source]