Mercurial > molko
changeset 296:032aeb430424
doc: document zfile
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 10 Mar 2021 18:39:50 +0100 |
parents | aec448037320 |
children | 6151152d009c |
files | doc/docs/dev/api/core/zfile.md doc/mkdocs.yml |
diffstat | 2 files changed, 53 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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 <core/zfile.h> +``` + +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