---
name: "zip_fdopen"
section: "3"
platform: "linux"
package: "libzip"
version: "1.11.4-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/zip_fdopen"
---

# zip\_fdopen(3)

open zip archive using open file descriptor

## NAME

**zip\_fdopen** – open zip archive using open file descriptor

## LIBRARY

libzip (-lzip)

## SYNOPSIS

**#include \<zip.h\>**

*zip\_t* *\**\

**zip\_fdopen**(*int fd*, *int flags*, *int \*errorp*);

## DESCRIPTION

The zip archive specified by the open file descriptor *fd* is opened and a pointer to a *struct* *zip*, used to manipulate the archive, is returned. In contrast to [zip\_open(3)](/zip_open/3.md), using **zip\_fdopen** the archive can only be opened in read-only mode. The *fd* argument may not be used any longer after calling **zip\_fdopen**. The *flags* are specified by *or*'ing the following values, or 0 for none of them.

- ZIP\_CHECKCONS

  Perform additional stricter consistency checks on the archive, and error if they fail.

If an error occurs and *errorp* is non-NULL, it will be set to the corresponding error code.

## RETURN VALUES

Upon successful completion **zip\_fdopen**() returns a *struct* *zip* pointer, and *fd* should not be used any longer, nor passed to [close(2)](/close/2.md). Otherwise, NULL is returned and *\*errorp* is set to indicate the error. In the error case, *fd* remains unchanged.

## ERRORS

The file specified by *fd* is prepared for use by [libzip(3)](/libzip/3.md) unless:

- \[ZIP\_ER\_INCONS\]

  Inconsistencies were found in the file specified by *path*. This error is often caused by specifying ZIP\_CHECKCONS but can also happen without it.

- \[ZIP\_ER\_INVAL\]

  The *flags* argument is invalid. Not all [zip\_open(3)](/zip_open/3.md) flags are allowed for **zip\_fdopen**, see DESCRIPTION.

- \[ZIP\_ER\_MEMORY\]

  Required memory could not be allocated.

- \[ZIP\_ER\_NOZIP\]

  The file specified by *fd* is not a zip archive.

- \[ZIP\_ER\_OPEN\]

  The file specified by *fd* could not be prepared for use by [libzip(3)](/libzip/3.md).

- \[ZIP\_ER\_OPNOTSUPP\]

  This functionality has been disabled at compile time.

- \[ZIP\_ER\_READ\]

  A read error occurred; see *errno* for details.

- \[ZIP\_ER\_SEEK\]

  The file specified by *fd* does not allow seeks.

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_close(3)](/zip_close/3.md), [zip\_error\_strerror(3)](/zip_error_strerror/3.md), [zip\_open(3)](/zip_open/3.md)

## HISTORY

**zip\_fdopen**() was added in libzip 1.0.

## AUTHORS

Dieter Baron ⟨*dillo@nih.at*⟩ and Thomas Klausner ⟨*wiz@gatalith.at*⟩
