ISOMedia.FileSlice (ISOMedia v0.1.0)

Copy Markdown View Source

An inert reference to a byte range on disk: %FileSlice{path, offset, length}.

A leaf box may carry a FileSlice as its data instead of an in-memory binary, so bulk payloads (notably mdat) are never loaded into memory. The bytes are read or streamed on demand; nothing here holds an open file handle.

Summary

Functions

Read the slice's bytes into a binary (opens, preads, closes).

Stream the slice's bytes to an already-open (raw) io_device in chunk_size chunks. The source is opened once (callback form, so it closes even if a write raises) and read sequentially.

Types

t()

@type t() :: %ISOMedia.FileSlice{
  length: non_neg_integer(),
  offset: non_neg_integer(),
  path: Path.t()
}

Functions

read(file_slice)

Read the slice's bytes into a binary (opens, preads, closes).

stream(file_slice, io_device, chunk_size \\ 65536)

Stream the slice's bytes to an already-open (raw) io_device in chunk_size chunks. The source is opened once (callback form, so it closes even if a write raises) and read sequentially.