---
name: "zip_file_set_comment"
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_file_set_comment"
---

# zip\_file\_set\_comment(3)

set comment for file in zip

## NAME

**zip\_file\_set\_comment** – set comment for file in zip

## LIBRARY

libzip (-lzip)

## SYNOPSIS

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

*int*\

**zip\_file\_set\_comment**(*zip\_t \*archive*, *zip\_uint64\_t index*, *const char \*comment*, *zip\_uint16\_t len*, *zip\_flags\_t flags*);

## DESCRIPTION

The **zip\_file\_set\_comment**() function sets the comment for the file at position *index* in the zip archive to *comment* of length *len*. If *comment* is NULL and *len* is 0, the file comment will be removed. The *flags* argument can be any of:

- ZIP\_FL\_ENC\_GUESS

  Guess encoding of *comment* (default). (Only CP-437 and UTF-8 are recognized.)

- ZIP\_FL\_ENC\_UTF\_8

  Interpret *comment* as UTF-8.

- ZIP\_FL\_ENC\_CP437

  Interpret *comment* as code page 437 (CP-437).

## RETURN VALUES

Upon successful completion 0 is returned. Otherwise, -1 is returned and the error information in *archive* is set to indicate the error.

## ERRORS

**zip\_file\_set\_comment**() fails if:

- \[ZIP\_ER\_INVAL\]

  *index* is not a valid file index in *archive*, or *len* is less than 0 or longer than the maximum comment length in a zip file (65535), or *comment* is not a valid UTF-8 encoded string.

- \[ZIP\_ER\_MEMORY\]

  Required memory could not be allocated.

- \[ZIP\_ER\_RDONLY\]

  The *archive* was opened in read-only mode.

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_file\_get\_comment(3)](/zip_file_get_comment/3.md), [zip\_get\_archive\_comment(3)](/zip_get_archive_comment/3.md), [zip\_set\_archive\_comment(3)](/zip_set_archive_comment/3.md)

## HISTORY

**zip\_file\_set\_comment**() was added in libzip 0.11.

## AUTHORS

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