Skip to content

Compression and hashing

NXArchive

NXArchive.nxproject describes the archive library, its native codec builds and its compiler-native runtime package. It publishes source and include paths, native object directories and compiled-package outputs. The runtime-package build requires the matching Nexus Pascal package SDK.

NXArchive provides ZIP, gzip, tar and related archive/codec support. Its TNXSevenZipReader reads a borrowed seekable TStream, lists entries and extracts them to streams. Keep the input stream alive for the reader's lifetime. Solid folders require a decoded-block buffer; decoding verifies CRCs.

The 7z reader supports Copy, LZMA, LZMA2, PPMd7 and supported filter chains. Encrypted archives and 7z creation are unsupported. The LZMA SDK container decoder is compiled with LLVM into objects linked into the Pascal application; it does not require a 7-Zip installation or a decoder DLL. The retained SDK sources and provenance are covered in the central attribution record.

ZIP legacy filename fallback uses Windows-1252; it is not arbitrary code-page detection. Gzip TestItemAt validates all member CRCs. Ordinary extraction's strictness is controlled by STRICTGZIP. Cabinet API operations are Windows-only.

Pascal and native C in one dependency graph

NXArchive retains Abbrevia-derived Pascal code alongside native C codec sources. Its provider builds LZMA SDK, PPMd, and WavPack objects through LLVM, and bzip2 through a separate shared-library operation. It publishes Pascal sources, headers, object directories, and library directories to its consumers.

The SevenZip unit names its linked objects and declares cdecl entry points into the C adapter. Requiring the provider coordinates the native build and lookup paths; those declarations and link directives establish the actual interface. See C/C++ dependencies in Pascal projects for the workflow, concrete source links, and deployment responsibilities.

LZMA stream lifetime

Decompression is synchronous. Compression writes asynchronously to its borrowed destination stream. Use one producer caller and keep the destination alive until completion. It must permit access from the compression thread. Unix applications need the normal cthreads initialization.

lCompressor := TNXLZMACompressionStream.Create(lOutput);
try
  lCompressor.WriteBuffer(lData[0], Length(lData));
  LzmaCheck(lCompressor.WaitForCompressionToFinish);
finally
  lCompressor.Free;
end;

Completion closes input, joins the worker and reports the first codec/header error; repeated completion is allowed. Writes propagate worker failure. Destruction joins for cleanup but does not raise the compression result. IsBusy is a status query, not a substitute for checking completion.

PasZLib

The Nexus Pascal paszlib package supplies Pascal zlib streams, gzip and ZIP support. Its NO_DEFLATE configuration is read-only and rejects writer operations.

HashLib4Pascal

The package exposes the upstream Hlp* APIs for digests, HMAC, checksums and key derivation. hashlib4pascal/HashLib4Pascal.nxproject publishes the library sources and dependencies for consuming projects. The library does not introduce a compiler dependency into the hashing APIs.

Licenses and incorporated-source provenance are in attribution.