comparison doc/docs/dev/api/core/zfile.md @ 296:032aeb430424

doc: document zfile
author David Demelier <markand@malikania.fr>
date Wed, 10 Mar 2021 18:39:50 +0100
parents
children
comparison
equal deleted inserted replaced
295:aec448037320 296:032aeb430424
1 # Module: zfile
2
3 Synopsis
4
5 ```c
6 #include <core/zfile.h>
7 ```
8
9 Open potentially compressed file through [ZSTD][] using C `FILE` interface.
10
11 ## Structs
12
13 ### zfile
14
15 This structure owns the context for loading the file and must be kept until the
16 FILE pointer is no longer necessary.
17
18 | Field | Access | Type |
19 |-------------------|--------|--------------------------------------------------|
20 | [fp](#fp) | (+) | `FILE *` |
21
22 #### fp
23
24 The C file pointer to read. It is opened in read-only text mode and must not be
25 closed, free'd or anything else.
26
27 ## Functions
28
29 ### zfile\_open
30
31 Open a file from `path` which can be compressed using [ZSTD][] or kept plain. If
32 compressed the data is decompressed transparently and stored into the structure
33 context `zf`.
34
35 Returns -1 on failure and 0 on success, in this case you can access the `fp`
36 field member to perform read operations.
37
38 ```c
39 int
40 zfile_open(struct zfile *zf, const char *path)
41 ```
42
43 ### zfile\_close
44
45 Close the file context `zf`.
46
47 ```c
48 void
49 zfile_close(struct zfile *zf)
50 ```
51
52 [ZSTD]: http://zstandard.org