---
name: "zip_file_get_external_attributes"
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_get_external_attributes"
---

# zip\_file\_get\_external\_attributes(3)

get external attributes for file in zip

## NAME

**zip\_file\_get\_external\_attributes** – get external attributes for file in zip

## LIBRARY

libzip (-lzip)

## SYNOPSIS

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

*int*\

**zip\_file\_get\_external\_attributes**(*zip\_t \*archive*, *zip\_uint64\_t index*, *zip\_flags\_t flags*, *zip\_uint8\_t \*opsys*, *zip\_uint32\_t \*attributes*);

## DESCRIPTION

The **zip\_file\_get\_external\_attributes**() function returns the operating system and external attributes for the file at position *index* in the zip archive. The external attributes usually contain the operating system-specific file permissions. If *flags* is set to ZIP\_FL\_UNCHANGED, the original unchanged values are returned. If *opsys* or *attributes* are NULL, they are not filled in.

The following operating systems are defined by the zip specification:

-

  ZIP\_OPSYS\_ACORN\_RISC

-

  ZIP\_OPSYS\_ALTERNATE\_MVS

-

  ZIP\_OPSYS\_AMIGA

-

  ZIP\_OPSYS\_ATARI\_ST

-

  ZIP\_OPSYS\_BEOS

-

  ZIP\_OPSYS\_CPM

-

  ZIP\_OPSYS\_DOS

-

  ZIP\_OPSYS\_MACINTOSH

-

  ZIP\_OPSYS\_MVS

-

  ZIP\_OPSYS\_OPENVMS

-

  ZIP\_OPSYS\_OS\_2

-

  ZIP\_OPSYS\_OS\_400

-

  ZIP\_OPSYS\_OS\_X

-

  ZIP\_OPSYS\_TANDEM

-

  ZIP\_OPSYS\_UNIX

-

  ZIP\_OPSYS\_VFAT

-

  ZIP\_OPSYS\_VM\_CMS

-

  ZIP\_OPSYS\_VSE

-

  ZIP\_OPSYS\_WINDOWS\_NTFS (uncommon, use ZIP\_OPSYS\_DOS instead)

-

  ZIP\_OPSYS\_Z\_SYSTEM

The defines above follow the PKWARE Inc. Appnote; please note that the InfoZIP Appnote has a slightly different mapping.

## RETURN VALUES

Upon successful completion, 0 is returned. In case of an error, -1 is returned and the error code in *archive* is set to indicate the error.

## EXAMPLES

The following code can be used to expand *attributes* if the operating system is ZIP\_OPSYS\_DOS.

```
#include <sys/stat.h>
#define FA_RDONLY       0x01            // FILE_ATTRIBUTE_READONLY
#define FA_DIREC        0x10            // FILE_ATTRIBUTE_DIRECTORY
static mode_t
_zip_dos_attr2mode(zip_uint32_t attr)
{
   mode_t m = S_IRUSR | S_IRGRP | S_IROTH;
   if (0 == (attr & FA_RDONLY))
      m |= S_IWUSR | S_IWGRP | S_IWOTH;
   if (attr & FA_DIREC)
      m = (S_IFDIR | (m & ~S_IFMT)) | S_IXUSR | S_IXGRP | S_IXOTH;
   return m;
}
```

## ERRORS

**zip\_file\_get\_external\_attributes**() fails if:

- \[ZIP\_ER\_INVAL\]

  *index* is not a valid file index in *archive*.

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_file\_set\_external\_attributes(3)](/zip_file_set_external_attributes/3.md)

## HISTORY

**zip\_file\_get\_external\_attributes**() was added in libzip 0.11.2.

## AUTHORS

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