ObjFW
OFZIPArchiveEntry.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFObject.h"
17 
18 OF_ASSUME_NONNULL_BEGIN
19 
22 enum {
23  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_NONE = 0,
24  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_SHRINK = 1,
25  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_REDUCE_FACTOR_1 = 2,
26  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_REDUCE_FACTOR_2 = 3,
27  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_REDUCE_FACTOR_3 = 4,
28  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_REDUCE_FACTOR_4 = 5,
29  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_IMPLODE = 6,
30  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_DEFLATE = 8,
31  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_DEFLATE64 = 9,
32  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_BZIP2 = 12,
33  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_LZMA = 14,
34  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_WAVPACK = 97,
35  OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_PPMD = 98
36 };
37 
82 };
83 
84 enum {
85  OF_ZIP_ARCHIVE_ENTRY_EXTRA_FIELD_ZIP64 = 0x0001
86 };
87 
88 @class OFString;
89 @class OFData;
90 @class OFFile;
91 @class OFDate;
92 
100 {
101  uint16_t _versionMadeBy, _minVersionNeeded, _generalPurposeBitFlag;
102  uint16_t _compressionMethod;
103  uint16_t _lastModifiedFileTime, _lastModifiedFileDate;
104  uint32_t _CRC32;
105  uint64_t _compressedSize, _uncompressedSize;
106  OFString *_fileName;
107  OFData *_Nullable _extraField;
108  OFString *_Nullable _fileComment;
109  uint32_t _startDiskNumber;
110  uint16_t _internalAttributes;
111  uint32_t _versionSpecificAttributes;
112  int64_t _localFileHeaderOffset;
113  OF_RESERVE_IVARS(OFZIPArchiveEntry, 4)
114 }
115 
119 @property (readonly, copy, nonatomic) OFString *fileName;
120 
124 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic)
125  OFString *fileComment;
126 
132 @property OF_NULLABLE_PROPERTY (readonly, copy, nonatomic) OFData *extraField;
133 
141 @property (readonly, nonatomic) uint16_t versionMadeBy;
142 
150 @property (readonly, nonatomic) uint16_t minVersionNeeded;
151 
157 @property (readonly, retain, nonatomic) OFDate *modificationDate;
158 
171 @property (readonly, nonatomic) uint16_t compressionMethod;
172 
176 @property (readonly, nonatomic) uint64_t compressedSize;
177 
181 @property (readonly, nonatomic) uint64_t uncompressedSize;
182 
186 @property (readonly, nonatomic) uint32_t CRC32;
187 
194 @property (readonly, nonatomic) uint32_t versionSpecificAttributes;
195 
201 @property (readonly, nonatomic) uint16_t generalPurposeBitFlag;
202 
209 + (instancetype)entryWithFileName: (OFString *)fileName;
210 
211 - (instancetype)init OF_UNAVAILABLE;
212 
220 - (instancetype)initWithFileName: (OFString *)fileName;
221 @end
222 
223 #ifdef __cplusplus
224 extern "C" {
225 #endif
232 extern OFString *of_zip_archive_entry_version_to_string(uint16_t version);
233 
242  uint16_t compressionMethod);
243 
255 extern size_t of_zip_archive_entry_extra_field_find(OFData *extraField,
256  uint16_t tag, uint16_t *size);
257 #ifdef __cplusplus
258 }
259 #endif
260 
261 OF_ASSUME_NONNULL_END
262 
263 #import "OFMutableZIPArchiveEntry.h"
of_zip_archive_entry_attribute_compatibility
Attribute compatibility part of ZIP versions.
Definition: OFZIPArchiveEntry.h:41
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_ALTERNATE_MVS
Definition: OFZIPArchiveEntry.h:73
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_BEOS
Definition: OFZIPArchiveEntry.h:75
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_CP_M
Definition: OFZIPArchiveEntry.h:61
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_VFAT
Definition: OFZIPArchiveEntry.h:71
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_WINDOWS_NTFS
Definition: OFZIPArchiveEntry.h:63
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_UNIX
Definition: OFZIPArchiveEntry.h:49
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_OS_X
Definition: OFZIPArchiveEntry.h:81
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_OS2_HPFS
Definition: OFZIPArchiveEntry.h:55
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_TANDEM
Definition: OFZIPArchiveEntry.h:77
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_AMIGA
Definition: OFZIPArchiveEntry.h:45
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_VSE
Definition: OFZIPArchiveEntry.h:67
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_Z_SYSTEM
Definition: OFZIPArchiveEntry.h:59
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_OPENVMS
Definition: OFZIPArchiveEntry.h:47
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_OS_400
Definition: OFZIPArchiveEntry.h:79
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_MSDOS
Definition: OFZIPArchiveEntry.h:43
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_MACINTOSH
Definition: OFZIPArchiveEntry.h:57
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_ACORN_RISC_OS
Definition: OFZIPArchiveEntry.h:69
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_ATARI_ST
Definition: OFZIPArchiveEntry.h:53
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_MVS
Definition: OFZIPArchiveEntry.h:65
@ OF_ZIP_ARCHIVE_ENTRY_ATTR_COMPAT_VM_CMS
Definition: OFZIPArchiveEntry.h:51
size_t of_zip_archive_entry_extra_field_find(OFData *extraField, uint16_t tag, uint16_t *size)
Gets a pointer to and the size of the extensible data field with the specified tag.
Definition: OFZIPArchiveEntry.m:146
OFString * of_zip_archive_entry_compression_method_to_string(uint16_t compressionMethod)
Convers the ZIP entry compression method to a string.
Definition: OFZIPArchiveEntry.m:111
OFString * of_zip_archive_entry_version_to_string(uint16_t version)
Converts the ZIP entry version to a string.
Definition: OFZIPArchiveEntry.m:33
A class for storing arbitrary data in an array.
Definition: OFData.h:40
A class for storing, accessing and comparing dates.
Definition: OFDate.h:36
A class which provides methods to read and write files.
Definition: OFFile.h:39
The root class for all other classes inside ObjFW.
Definition: OFObject.h:520
A class for handling strings.
Definition: OFString.h:132
A class which represents an entry in the central directory of a ZIP archive.
Definition: OFZIPArchiveEntry.h:101
A protocol for the creation of copies.
Definition: OFObject.h:1187
A protocol for the creation of mutable copies.
Definition: OFObject.h:1208