Skip to content

feat(ncz): add parseNczHeader to read NCZ metadata without decompressing#40

Merged
TooTallNate merged 1 commit into
mainfrom
feat/ncz-parse-header
Jun 26, 2026
Merged

feat(ncz): add parseNczHeader to read NCZ metadata without decompressing#40
TooTallNate merged 1 commit into
mainfrom
feat/ncz-parse-header

Conversation

@TooTallNate

Copy link
Copy Markdown
Owner

Summary

  • Adds an exported parseNczHeader(blob) to @tootallnate/ncz that parses an NCZ's metadata header (section table, optional block table, reconstructed NCA size, and compressed-data offset) by reading only the small header region — no decompression.
  • decompressNcz now reuses this helper internally (steps 2–5 extracted), so there's a single source of truth for the header layout.

Why

Callers that repackage NSZ→NSP need the reconstructed NCA size up front (to compute a PFS0 layout and HTTP Content-Length) before streaming the decompression. Previously that logic was buried inside decompressNcz with no way to get the size without committing to a full decompress. sys-autopilot's host-side NSZ installer is the first consumer.

Notes

  • New public API surface: parseNczHeader() + ParsedNczHeader interface. Backward compatible — minor bump (changeset included).
  • No behavior change to decompressNcz; it just delegates parsing to the new helper.

Exposes the section/block-table parsing that decompressNcz already does
internally, so callers can compute the reconstructed NCA size up front
(e.g. to build a PFS0/NSP layout and Content-Length) before streaming
the decompression. decompressNcz now reuses this helper.
@changeset-bot

changeset-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 46dd0b0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@tootallnate/ncz Minor
nx-archive Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nro-editor Ready Ready Preview, Comment Jun 26, 2026 8:31am
nsp-forwarder Building Building Preview Jun 26, 2026 8:31am
nx-archive Ready Ready Preview, Comment Jun 26, 2026 8:31am
rom-id Ready Ready Preview, Comment Jun 26, 2026 8:31am

@TooTallNate TooTallNate merged commit bb67c6c into main Jun 26, 2026
7 checks passed
@TooTallNate TooTallNate deleted the feat/ncz-parse-header branch June 26, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant