1ZIP_FILE_GET_EXTERNAL... BSD Library Functions Manual ZIP_FILE_GET_EXTERNAL...
2

NAME

4     zip_file_get_external_attributes — get external attributes for file in
5     zip
6

LIBRARY

8     libzip (-lzip)
9

SYNOPSIS

11     #include <zip.h>
12
13     int
14     zip_file_get_external_attributes(zip_t *archive, zip_uint64_t index,
15         zip_flags_t flags, zip_uint8_t *opsys, zip_uint32_t *attributes);
16

DESCRIPTION

18     The zip_file_get_external_attributes() function returns the operating
19     system and external attributes for the file at position index in the zip
20     archive.  The external attributes usually contain the operating system-
21     specific file permissions.  If flags is set to ZIP_FL_UNCHANGED, the
22     original unchanged values are returned.  If opsys or attributes are NULL,
23     they are not filled in.
24
25     The following operating systems are defined by the zip specification:
26           ZIP_OPSYS_ACORN_RISC
27           ZIP_OPSYS_ALTERNATE_MVS
28           ZIP_OPSYS_AMIGA
29           ZIP_OPSYS_ATARI_ST
30           ZIP_OPSYS_BEOS
31           ZIP_OPSYS_CPM
32           ZIP_OPSYS_DOS
33           ZIP_OPSYS_MACINTOSH
34           ZIP_OPSYS_MVS
35           ZIP_OPSYS_OPENVMS
36           ZIP_OPSYS_OS_2
37           ZIP_OPSYS_OS_400
38           ZIP_OPSYS_OS_X
39           ZIP_OPSYS_TANDEM
40           ZIP_OPSYS_UNIX
41           ZIP_OPSYS_VFAT
42           ZIP_OPSYS_VM_CMS
43           ZIP_OPSYS_VSE
44           ZIP_OPSYS_WINDOWS_NTFS (uncommon, use ZIP_OPSYS_DOS instead)
45           ZIP_OPSYS_Z_SYSTEM
46
47     The defines above follow the PKWARE Inc. Appnote; please note that the
48     InfoZIP Appnote has a slightly different mapping.
49

RETURN VALUES

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

EXAMPLES

55     The following code can be used to expand attributes if the operating sys‐
56     tem is ZIP_OPSYS_DOS.
57
58     #include <sys/stat.h>
59
60     #define FA_RDONLY       0x01            // FILE_ATTRIBUTE_READONLY
61     #define FA_DIREC        0x10            // FILE_ATTRIBUTE_DIRECTORY
62
63     static mode_t
64     _zip_dos_attr2mode(zip_uint32_t attr)
65     {
66        mode_t m = S_IRUSR | S_IRGRP | S_IROTH;
67        if (0 == (attr & FA_RDONLY))
68           m |= S_IWUSR | S_IWGRP | S_IWOTH;
69
70        if (attr & FA_DIREC)
71           m = (S_IFDIR | (m & ~S_IFMT)) | S_IXUSR | S_IXGRP | S_IXOTH;
72
73        return m;
74     }
75

ERRORS

77     zip_file_get_external_attributes() fails if:
78
79     [ZIP_ER_INVAL]     index is not a valid file index in archive.
80

SEE ALSO

82     libzip(3), zip_file_set_external_attributes(3)
83

HISTORY

85     zip_file_get_external_attributes() was added in libzip 0.11.2.
86

AUTHORS

88     Dieter Baron <dillo@nih.at> and Thomas Klausner <tk@giga.or.at>
89
90BSD                            December 18, 2017                           BSD
Impressum