Repository navigation
Add ZSTD file access API (fopen/fread/fwrite/fclose) - #4820
Open
ceedot-rock wants to merge 1 commit into
Open
ceedot-rock wants to merge 1 commit into
ceedot-rock wants to merge 1 commit into
Conversation
Decompresses one source buffer into an ordered array of ZSTD_outBuffer destinations, filling them in order. Built on top of ZSTD_decompressStream, so multiple concatenated frames are supported. Returns the total bytes written, or ZSTD_error_dstSize_tooSmall when the combined destination capacity falls short. Adds tests/scatterGatherTest.c (8 tests) and a Makefile target.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #199.
Adds the file convenience API this issue has asked for since 2016: an opaque ZSTD_FCtx with ZSTD_fopen(path, mode) / ZSTD_fopenLevel(path, mode, level), ZSTD_fread, ZSTD_fwrite, ZSTD_fclose, plus ZSTD_ferror() as a sticky error query (the gzerror parallel).
Built on the streaming API plus stdio, so the codec itself is untouched. Modes are r/w (b/t accepted and ignored); anything else, including append, fails cleanly. Deliberately the core six of zlib's ~20: no append, no fdopen, no seek, no dict support in this cut - easy to extend later without breaking the API.
Design notes for review: fclose returns 0 on success, otherwise the sticky ZSTD_ErrorCode; fwrite is all-or-nothing rather than partial counts; I/O errors collapse to ZSTD_error_GENERIC.
Tests: new tests/fileApiTest.c, 59 checks, 0 failures - text and 3MB binary roundtrips, odd chunk sizes, 1-byte stress, empty payloads, EOF semantics, levels 1/19/negative/clamped, full error-path matrix. Output decompresses with the zstd CLI and vice versa. ASan/UBSan clean, 500 fuzzer iterations clean.
Slid Phi Labs accepts donations to keep the lab independent.
Slid Phi Labs accepts donations to keep the lab independent: https://www.patreon.com/SlidPhiLabs