---
name: "zip_set_archive_flag"
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_set_archive_flag"
---

# zip\_set\_archive\_flag(3)

set zip archive flag

## NAME

**zip\_set\_archive\_flag** – set zip archive flag

## LIBRARY

libzip (-lzip)

## SYNOPSIS

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

*int*\

**zip\_set\_archive\_flag**(*zip\_t \*archive*, *zip\_flags\_t flag*, *int value*);

## DESCRIPTION

The **zip\_set\_archive\_flag**() function sets the flag *flag* for the archive *archive* to the value *value*.

Supported flags are:

- ZIP\_AFL\_CREATE\_OR\_KEEP\_FILE\_FOR\_EMPTY\_ARCHIVE

  If this flag is cleared, the archive file will be removed if the archive is empty. If it is set, an empty archive will be created, which is not recommended by the zip specification.

- ZIP\_AFL\_RDONLY

  If this flag is set, no modification to the archive are allowed. This flag can only be cleared if it was manually set with **zip\_set\_archive\_flag**, not if the archive was opened read-only.

- ZIP\_AFL\_WANT\_TORRENTZIP

  If this flag is set, the archive will be written in torrentzip format.

## RETURN VALUES

Upon successful completion 0 is returned, and -1 if an error occurred.

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_get\_archive\_flag(3)](/zip_get_archive_flag/3.md)

## HISTORY

**zip\_set\_archive\_flag**() was added in libzip 0.9. In libzip 0.11 the type of *flag* was changed from *int* to *zip\_flags\_t*. ZIP\_AFL\_CREATE\_OR\_KEEP\_FILE\_FOR\_EMPTY\_ARCHIVE and ZIP\_AFL\_WANT\_TORRENTZIP were added in libzip 1.10.0.

## AUTHORS

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