---
name: "zzip_disk_fopen"
section: "3"
platform: "linux"
package: "libzzip-dev"
version: "0.13.72+dfsg.1-1.1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/zzip_disk_fopen"
---

# zzip\_disk\_fopen(3)

openening a file part wrapped within a (mmapped) zip archive

## NAME

zzip\_disk\_fopen, zzip\_disk\_entry\_fopen, zzip\_disk\_fread, zzip\_disk\_fclose, zzip\_disk\_feof -  openening a file part wrapped within a (mmapped) zip archive

## SYNOPSIS

```
#include <zzip/mmapped.h>

zzip__new__ ZZIP_DISK_FILE *
zzip_disk_fopen(ZZIP_DISK * disk, char *filename)
zzip__new__ ZZIP_DISK_FILE *
zzip_disk_entry_fopen(ZZIP_DISK * disk, ZZIP_DISK_ENTRY * entry)
zzip_size_t
zzip_disk_fread(void *ptr, zzip_size_t sized, zzip_size_t nmemb,
                ZZIP_DISK_FILE * file)
int
zzip_disk_fclose(ZZIP_DISK_FILE * file)
int
zzip_disk_feof(ZZIP_DISK_FILE * file)
```

## DESCRIPTION

 The *zzip\_disk\_fopen* function opens a file found by name, so it does a search into the zip central directory with *zzip\_disk\_findfile* and whatever is found first is given to *zzip\_disk\_entry\_fopen*

 The *zzip\_disk\_fopen* function may return null on errors (errno).

 the ZZIP\_DISK\_FILE\* is rather simple in just encapsulating the arguments given to the *zzip\_disk\_entry\_fopen* function plus a zlib deflate buffer. Note that the ZZIP\_DISK pointer does already contain the full mmapped file area of a zip disk, so open()ing a file part within that area happens to be a lookup of its bounds and encoding. That information is memorized on the ZZIP\_DISK\_FILE so that subsequent \_read() operations will be able to get the next data portion or return an eof condition for that file part wrapped in the zip archive.

 The *zzip\_disk\_entry\_fopen* function may return null on errors (errno = ENOMEM\|EBADMSG).

 The *zzip\_disk\_fread* function reads more bytes into the output buffer specified as arguments. The return value is null on eof or error, the stdio-like interface can not distinguish between these so you need to check with *zzip\_disk\_feof* for the difference.

 The *zzip\_disk\_fclose* function releases any zlib decoder info needed for decompression and dumps the ZZIP\_DISK\_FILE\* then.

 The *zzip\_disk\_fclose* function always returns 0.

 The *zzip\_disk\_feof* function allows to distinguish an error from an eof condition. Actually, if we found an error but we did already reach eof then we just keep on saying that it was an eof, so the app can just continue.

 The *zzip\_disk\_feof* function returns EOF in case and 0 when not at the end of file.

## AUTHOR

 Guido Draheim \<guidod@gmx.de\>

## COPYRIGHT

 Copyright (c)Guido Draheim, use under copyleft (LGPL,MPL)
