# HG changeset patch # User David Demelier # Date 1615397990 -3600 # Node ID 032aeb43042405f1a77cded6ef3cfe39448af2a7 # Parent aec448037320e6ec7cb87420d931611067e9dc9b doc: document zfile diff -r aec448037320 -r 032aeb430424 doc/docs/dev/api/core/zfile.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/docs/dev/api/core/zfile.md Wed Mar 10 18:39:50 2021 +0100 @@ -0,0 +1,52 @@ +# Module: zfile + +Synopsis + +```c +#include +``` + +Open potentially compressed file through [ZSTD][] using C `FILE` interface. + +## Structs + +### zfile + +This structure owns the context for loading the file and must be kept until the +FILE pointer is no longer necessary. + +| Field | Access | Type | +|-------------------|--------|--------------------------------------------------| +| [fp](#fp) | (+) | `FILE *` | + +#### fp + +The C file pointer to read. It is opened in read-only text mode and must not be +closed, free'd or anything else. + +## Functions + +### zfile\_open + +Open a file from `path` which can be compressed using [ZSTD][] or kept plain. If +compressed the data is decompressed transparently and stored into the structure +context `zf`. + +Returns -1 on failure and 0 on success, in this case you can access the `fp` +field member to perform read operations. + +```c +int +zfile_open(struct zfile *zf, const char *path) +``` + +### zfile\_close + +Close the file context `zf`. + +```c +void +zfile_close(struct zfile *zf) +``` + +[ZSTD]: http://zstandard.org diff -r aec448037320 -r 032aeb430424 doc/mkdocs.yml --- a/doc/mkdocs.yml Wed Mar 10 16:40:02 2021 +0100 +++ b/doc/mkdocs.yml Wed Mar 10 18:39:50 2021 +0100 @@ -84,3 +84,4 @@ - translate: dev/api/core/translate.md - util: dev/api/core/util.md - window: dev/api/core/window.md + - zfile: dev/api/core/zfile.md