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/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) #

Class Method Detail

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

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


Instance Method Detail

def [](rel_path : String) : Item #

Array access alias for get.


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

Nilable array access alias for get?.


def add(item : Item) : Item #

Registers an item into this volume.


def default_chunk_size : UInt32 #

def default_chunk_size=(default_chunk_size : UInt32) #

def default_compression : CompressionType #

def default_compression=(default_compression : CompressionType) #

def each_file(&block : Item -> ) : Nil #

Iterates over all items in this volume.


def empty? : Bool #

Checks if this volume has no files.


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

Extracts all files from this volume into destination_dir on disk.


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

Extracts a subfolder matching prefix into destination_dir.


def files : Array(String) #

Returns all relative virtual file paths registered in this volume.


def files_with_prefix(prefix : String) : Array(String) #

Returns all relative paths starting with the given prefix.


def get(rel_path : String) : Item #

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


def get?(rel_path : String) : Item | Nil #

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


def glob(pattern : String, & : Item -> ) : Nil #

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


def glob(pattern : String) : Array(Item) #

Returns an array of items matching the glob pattern.


def has_file?(rel_path : String) : Bool #

Checks if a relative path exists in this volume.


def items : Hash(String, Item) #

def mount_point : String #

def mount_point=(new_mount : String) #

def mount_prefix_with_slash : String #

def name : String #

def priority : Int32 #

def priority=(priority : Int32) #

def size : Int32 #

Total number of files in this volume.