ObjFW
Loading...
Searching...
No Matches
OFZIPArchive.h
1/*
2 * Copyright (c) 2008-2024 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#import "OFString.h"
18#import "OFZIPArchiveEntry.h"
19
20OF_ASSUME_NONNULL_BEGIN
21
22@class OFArray OF_GENERIC(ObjectType);
23@class OFMutableArray OF_GENERIC(ObjectType);
24@class OFMutableDictionary OF_GENERIC(KeyType, ObjectType);
25@class OFSeekableStream;
26@class OFStream;
27@class OFZIPArchive;
28
34@protocol OFZIPArchiveDelegate <OFObject>
35@optional
45- (nullable OFSeekableStream *)archive: (OFZIPArchive *)archive
46 wantsPartNumbered: (unsigned int)partNumber
47 lastPartNumber: (unsigned int)lastPartNumber;
48@end
49
55OF_SUBCLASSING_RESTRICTED
57{
58#ifdef OF_ZIP_ARCHIVE_M
59@public
60#endif
61 OFObject <OFZIPArchiveDelegate> *_Nullable _delegate;
62 OF_KINDOF(OFStream *) _stream;
63 int64_t _offset;
64 uint_least8_t _mode;
65 uint32_t _diskNumber, _lastDiskNumber;
66@protected
67 uint32_t _centralDirectoryDisk;
68 uint64_t _centralDirectoryEntriesInDisk, _centralDirectoryEntries;
69 uint64_t _centralDirectorySize;
70 int64_t _centralDirectoryOffset;
71 OFString *_Nullable _archiveComment;
72#ifdef OF_ZIP_ARCHIVE_M
73@public
74#endif
75 OFMutableArray OF_GENERIC(OFZIPArchiveEntry *) *_entries;
77 *_pathToEntryMap;
78 OFStream *_Nullable _lastReturnedStream;
79}
80
84@property OF_NULLABLE_PROPERTY (assign, nonatomic)
85 OFObject <OFZIPArchiveDelegate> *delegate;
86
90@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *archiveComment;
91
100@property (readonly, nonatomic)
101 OFArray OF_GENERIC(OFZIPArchiveEntry *) *entries;
102
114+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode;
115
126+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode;
127
137+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI;
138
139- (instancetype)init OF_UNAVAILABLE;
140
153- (instancetype)initWithStream: (OFStream *)stream
154 mode: (OFString *)mode OF_DESIGNATED_INITIALIZER;
155
167- (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode;
168
194- (OFStream *)streamForReadingFile: (OFString *)path;
195
230- (OFStream *)streamForWritingEntry: (OFZIPArchiveEntry *)entry;
231
237- (void)close;
238@end
239
240#ifdef __cplusplus
241extern "C" {
242#endif
243extern uint32_t OFZIPArchiveReadField32(const uint8_t *_Nonnull *_Nonnull,
244 uint16_t *_Nonnull);
245extern uint64_t OFZIPArchiveReadField64(const uint8_t *_Nonnull *_Nonnull,
246 uint16_t *_Nonnull);
247#ifdef __cplusplus
248}
249#endif
250
251OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition OFArray.h:105
A class for representing IRIs, URIs, URLs and URNs, for parsing them as well as accessing parts of th...
Definition OFIRI.h:37
An abstract class for storing, adding and removing objects in an array.
Definition OFMutableArray.h:44
An abstract class for storing and changing objects in a dictionary.
Definition OFMutableDictionary.h:44
The root class for all other classes inside ObjFW.
Definition OFObject.h:688
A stream that supports seeking.
Definition OFSeekableStream.h:71
A base class for different types of streams.
Definition OFStream.h:188
A class for handling strings.
Definition OFString.h:135
A class which represents an entry in the central directory of a ZIP archive.
Definition OFZIPArchiveEntry.h:107
A class for accessing and manipulating ZIP files.
Definition OFZIPArchive.h:57