Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,26 @@ API between minor releases.
contents), and the `container-only` diagnostic. The project is `IsPackable=false` and is not published; it ships on a
`PlaIO` release tag when the reader decodes elements and geometry. See `docs/scene.md`.

- `PlaDocument.ReadPayload` decodes mode 2 (LZ) payloads. A payload may start with a 9-byte stream header with a
0x46 or 0x47 marker and matching packed and unpacked sizes. The token stream produces the block's declared unpacked size and may reference the
decompressed output of any preceding block of the file, so `ReadPayload` for a mode 2 block decodes the file from the
start into one global window; the cost of the call grows with the size of the file. Preceding blocks that do not
decode (false entries of the scan) are skipped and leave the window unchanged. A final match may omit the length byte
(the match length is the remainder of the output). Some blocks declare an output buffer larger than the stream
produces: the stream simply ends with the body, the produced bytes fill the head of the buffer and the tail stays
zero — the global window holds the buffer space, so directory positions keep addressing it. A back-reference beyond
the decoded stream throws `InvalidDataException`.

### Changed

- The release workflow follows the IOExtend release order: the NuGet packages are pushed before the GitHub release is
created (a refused first publication can be fixed and the job re-run, because `--skip-duplicate` makes the push
repeatable), and a tag whose version contains a hyphen is published as a prerelease. The changelog section for the
version is checked before anything is published.

- `PlaDocument.ReadPayload` no longer throws `NotSupportedException` for mode 2 blocks: all three storage modes
(raw, zero mask, LZ) decode now.

## [0.1.0] - 2026-11-12

### Added
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ release tag when the reader decodes elements and geometry (see [the scene adapte
- Detects the file kind from the first bytes: the container shared by `.pla` and `.pln`, or `.bimx`.
- Reads the container header and exposes its fields as raw values where their meaning is not documented.
- Indexes the `BL` and `DY` blocks of the container in one forward scan, without loading the whole file.
- Decodes block payloads stored raw (mode 0) or with zero masks (mode 1). Mode 2 (LZ) payloads are recognised but not
decoded, and some mode 1 blocks in real files do not decode (see [Limitations](#limitations)).
- Decodes block payloads stored raw (mode 0), with zero masks (mode 1), or with LZ compression (mode 2).
Some mode 1 blocks in real files do not decode (see [Limitations](#limitations)).
- Searches raw blocks for object directories (30-byte records of class number, position, count and object GUID).
- Reads the PNG cover image at the start of a `.bimx` file and reports where the rest of the content begins.

Expand Down Expand Up @@ -94,7 +94,6 @@ using (var document = PlaDocument.Open("project.pln"))

foreach (var block in document.Blocks)
{
if (block.Mode == PlaBlockMode.Lz) continue; // recognised, not decoded
try
{
byte[] payload = document.ReadPayload(block);
Expand All @@ -114,9 +113,9 @@ using (var bimx = BimxDocument.Open("model.bimx"))
File.WriteAllBytes("cover.png", bimx.ReadCover());
```

`PlaFile.DetectKind` tells the kinds apart before a file is opened. `ReadPayload` throws `NotSupportedException` for a
mode 2 (LZ) block and `InvalidDataException` for a payload that does not decode to its declared size. The library never
writes to the console and has no diagnostic output; problems are reported as exceptions.
`PlaFile.DetectKind` tells the kinds apart before a file is opened. `ReadPayload` throws `InvalidDataException` for a
payload that does not decode. Each mode 2 read rebuilds the decoded history of preceding blocks. The library reports
errors through exceptions.

See the [public API](docs/public-api.md) for the supported surface and [dependencies](docs/dependencies.md) for package
details.
Expand Down Expand Up @@ -208,7 +207,6 @@ included in the repository. Files from other versions are not tested.
## Limitations

- Version 0.1.0 is a preview. The API can change before 1.0.
- Mode 2 (LZ) payloads are recognised but not decoded; `ReadPayload` throws `NotSupportedException` for them.
- The meaning of the `pos` and `count` fields of a directory record is not known, so the addressing of objects is not
supported. Class numbers are not mapped to class names, and the contents of objects (elements, parameters, geometry)
are not read.
Expand Down
4 changes: 2 additions & 2 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The limits are fixed; the tool has no option to change them.
| --- | --- |
| At most 1048576 (2^20) blocks in one index | A file with more blocks is rejected with exit code 2. |
| Unpacked size of a block at most 2^28 bytes and at most 300 times its packed size plus 65536 | A block header outside these bounds is not taken as a block; the scan moves on. |
| Mode 2 (LZ) payloads | Recognised and listed, but not decoded. No command decodes payloads; `directory` reads raw blocks only. |
| Mode 2 (LZ) payloads | Listed by `blocks`. The CLI `directory` command reads raw blocks only. |
| Object directories | Searched in raw (mode 0) blocks of at least 1920 bytes, at most one per block. A directory needs at least 64 records whose extents mostly abut. The run that is reported is an estimate and can be shorter than the real directory. |

The meaning of `pos` and `count` in a directory record is not known, class numbers are not mapped to class names and the
Expand Down Expand Up @@ -153,6 +153,6 @@ case $? in
2) echo "the file cannot be read, or directories.json cannot be written" ;;
esac

# count the blocks whose payload is not decoded (mode 2)
# count the mode 2 blocks
plaio blocks project.pln | awk -F '\t' 'NR > 1 && $8 == "Lz"' | wc -l
```
5 changes: 2 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ using (var doc = PlaDocument.Open("project.pln"))

foreach (PlaBlock block in doc.Blocks)
{
if (block.Mode == PlaBlockMode.Lz) continue; // recognised, but ReadPayload throws NotSupportedException
try
{
byte[] payload = doc.ReadPayload(block);
Expand All @@ -64,10 +63,10 @@ using (var bimx = BimxDocument.Open("model.bimx"))

Use `PlaFile.DetectKind` to tell an FDB container (`.pla`, `.pln`) from a `.bimx` file before opening it.

The library never writes to the console and has no diagnostic writer. A file it cannot read is reported by an exception: `InvalidDataException` for data that is not the expected kind or is cut short, `NotSupportedException` for a mode 2 payload, and the usual I/O exceptions for a file that cannot be opened.
The library never writes to the console and has no diagnostic writer. A file it cannot read is reported by an exception: `InvalidDataException` for data that is not the expected kind, does not decode to its declared size, or is cut short, and the usual I/O exceptions for a file that cannot be opened.

The supported surface is listed in [Public API](public-api.md); every type is in the [API reference](api/PlaIO.yml).

## Status

PlaIO 0.1.0 is a preview and the API can change before 1.0. It does not decode mode 2 (LZ) payloads, does not interpret the position and count of directory records, does not map class numbers to class names and does not read object contents. In real files a small share of mode 1 blocks does not decode to its declared size, and `ReadPayload` throws `InvalidDataException` for them. The block index is found by scanning and may contain false entries.
PlaIO 0.1.0 is a preview and the API can change before 1.0. It does not interpret the position and count of directory records, does not map class numbers to class names and does not read object contents. In real files a small share of mode 1 blocks does not decode to its declared size, and `ReadPayload` throws `InvalidDataException` for them. The block index is found by scanning and may contain false entries.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PlaIO is a .NET library and command line tool that reads the container structure

- Detects the file kind from the first bytes of a file.
- Reads the header of the FDB container that `.pla` and `.pln` files share, and builds an index of its blocks.
- Decodes block payloads stored raw (mode 0) or zero-masked (mode 1). Mode 2 (LZ) payloads are recognised but not decoded, and a small share of mode 1 blocks in real files does not decode to its declared size.
- Decodes raw (mode 0), zero-mask (mode 1), and LZ (mode 2) payloads. A small share of mode 1 blocks in real files does not decode to its declared size.
- Searches raw blocks for object directories and returns their records as stored (class number, position, count, GUID).
- Reads the PNG cover image of a `.bimx` file.

Expand Down
4 changes: 2 additions & 2 deletions docs/public-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ The `PlaIO` package is the supported surface listed here; every public type is i
| `PlaDocument.Length` | Length of the file in bytes. |
| `PlaDocument.Header` | The `FdbHeader`. |
| `PlaDocument.Blocks` | The block index in file order, found by scanning from offset 32. No on-disk block map is known, so completeness is not claimed. The scan can take a byte run for a block header, so the index may contain false entries. In real files a small share of mode 1 blocks does not decode to its declared size, and `ReadPayload` throws `InvalidDataException` for them. |
| `PlaDocument.ReadPayload(PlaBlock block)` | The decoded payload of a block of this document. Decodes mode 0 and mode 1. Throws `NotSupportedException` for mode 2 (LZ), `InvalidDataException` when a mode 1 payload does not decode to the declared size or the file is cut short, and `ArgumentException` when the block is not from this document. |
| `PlaDocument.ReadPayload(PlaBlock block)` | The decoded payload of a block of this document. Decodes all three storage modes: raw (mode 0), zero masks (mode 1) and the LZ token stream (mode 2). A mode 2 payload may start with a 9-byte stream header with a 0x46 or 0x47 marker and matching packed and unpacked sizes. The token stream produces the block's declared unpacked size — some blocks declare a buffer larger than the stream produces, the tail of the buffer stays zero — and may reference the output of any preceding block, so the payload is produced by decoding every preceding block of the file in order into one global window; the cost of the call grows with the size of the file. Preceding blocks that do not decode (false entries of the scan) are skipped and leave the window unchanged. Throws `InvalidDataException` when a back-reference reaches beyond the decoded stream or the file is cut short, and `ArgumentException` when the block is not from this document. |
| `PlaDocument.FindDirectories()` | Searches every raw (mode 0) block large enough for 64 records of 30 bytes for an object directory, at most one per block. Recomputed on each call; mode 1 payloads are not searched. |
| `PlaDocument.Dispose()` | Releases the stream unless the document was opened with `leaveOpen`. |
| `FdbHeader` | `Size` (64), `LayoutVersion` (u16 at offset 8), `FormatVersion` (u16 at offset 10), `Field12` (u32 at offset 12; meaning not documented), `Raw` (the first min(64, file length) bytes; bytes 32..63 overlap the first block). |
| `PlaBlockMode` | `Raw` (0), `ZeroMask` (1, flag 0x100), `Lz` (2, flag 0x200; recognised, not decoded). |
| `PlaBlockMode` | `Raw` (0), `ZeroMask` (1, flag 0x100), `Lz` (2, flag 0x200). |
| `PlaBlock` | One indexed block: `Offset`, `Tag` (`BL` or `DY`), `Id` and `Kind` (raw), `Version` (0 or 1), `Flags` (raw), `SizeClass` (`Flags & 0xF`), `Mode`, `Guid` (present when flag 0x20 is set), `PackedSize`, `UnpackedSize`, `Extra` (present when flag 0x400 is set; raw), `PayloadOffset`, `HeaderLength`, `End`. |
| `ObjectDirectory` | A run of directory records inside a raw block: `Block`, `RecordOffset` (payload offset of the first record), `Phase` (`RecordOffset % 30`), `Records`, `AbuttingPairs`, `OverlappingPairs`, `DuplicatePositions`. The run is an estimate and can be shorter than the real directory: it stops after more than 8 consecutive records without an abutting neighbour. |
| `ObjectDirectoryRecord` | The 30-byte record `[u16 class][u64 pos][u32 count][GUID16]` as `ClassNumber`, `Position`, `Count`, `ObjectId`. The units of position and count are not documented, and the class number is not mapped to a class name. |
Expand Down
Loading
Loading