Table of Contents

Class PlaDocument

Namespace
PlaIO
Assembly
PlaIO.dll

An open FDB container (.pla or .pln): the header, the block index and payload decoding for modes 0 and 1. The file is never loaded whole; payloads are read on request. Not thread-safe.

public sealed class PlaDocument : IDisposable

Inheritance

Implements

Inherited Members

Properties

Blocks

The block index, in file order, built once by PlaIO.PlaDocument.Open(System.IO.Stream,System.Boolean). No on-disk block map is known, so the index is found by scanning (from offset 32, one byte at a time, skipping accepted payloads) and makes no claim of completeness. The scan can take a byte run for a block header, so the index may contain false entries, and in real files a small share of mode 1 blocks does not decode to its declared size.

public IReadOnlyList<PlaBlock> Blocks { get; }

Property Value

IReadOnlyList<PlaBlock>

Header

The container header.

public FdbHeader Header { get; }

Property Value

FdbHeader

Length

Length of the file in bytes.

public long Length { get; }

Property Value

long

Methods

Dispose()

Releases the stream unless the document was opened with leaveOpen.

public void Dispose()

FindDirectories()

Searches every raw block large enough for 64 records for an object directory (at most one per block). Computed on each call; reads the raw blocks one at a time. Mode-1 payloads are not searched.

public IReadOnlyList<ObjectDirectory> FindDirectories()

Returns

IReadOnlyList<ObjectDirectory>

Remarks

The work grows with the total size of the raw blocks: each block gets a linear pre-check at all 30 record alignments, and each alignment that passes costs one sort of its records; a block needs about 1.5 times its size in memory while it is searched.

Open(string)

Opens the file at path for reading.

public static PlaDocument Open(string path)

Parameters

path string

Returns

PlaDocument

Exceptions

InvalidDataException

The file is not an FDB container or is cut short.

Open(Stream, bool)

Opens a container from a readable, seekable stream. The document owns the stream unless leaveOpen is true; when this method throws, the stream stays with the caller.

public static PlaDocument Open(Stream stream, bool leaveOpen = false)

Parameters

stream Stream
leaveOpen bool

Returns

PlaDocument

Exceptions

ArgumentException

The stream cannot read or seek.

InvalidDataException

The data is not an FDB container or is cut short.

ReadPayload(PlaBlock)

The decoded payload of a block of this document.

public byte[] ReadPayload(PlaBlock block)

Parameters

block PlaBlock

Returns

byte[]

Exceptions

NotSupportedException

The block uses mode 2 (PlaIO.PlaBlockMode.Lz).

InvalidDataException

A mode-1 stream does not decode to the declared size, or the file is cut short.

ArgumentException

The block is not one of the PlaIO.PlaDocument.Blocks of this document.