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 program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#import "OFObject.h"
21#import "OFString.h"
22#import "OFZIPArchiveEntry.h"
23
24OF_ASSUME_NONNULL_BEGIN
25
26@class OFArray OF_GENERIC(ObjectType);
27@class OFMutableArray OF_GENERIC(ObjectType);
28@class OFMutableDictionary OF_GENERIC(KeyType, ObjectType);
29@class OFSeekableStream;
30@class OFStream;
31@class OFZIPArchive;
32
38@protocol OFZIPArchiveDelegate <OFObject>
39@optional
49- (nullable OFSeekableStream *)archive: (OFZIPArchive *)archive
50 wantsPartNumbered: (unsigned int)partNumber
51 lastPartNumber: (unsigned int)lastPartNumber;
52@end
53
59OF_SUBCLASSING_RESTRICTED
61{
62#ifdef OF_ZIP_ARCHIVE_M
63@public
64#endif
65 OFObject <OFZIPArchiveDelegate> *_Nullable _delegate;
66 OF_KINDOF(OFStream *) _stream;
67 int64_t _offset;
68 uint_least8_t _mode;
69 uint32_t _diskNumber, _lastDiskNumber;
70@protected
71 uint32_t _centralDirectoryDisk;
72 uint64_t _centralDirectoryEntriesInDisk, _centralDirectoryEntries;
73 uint64_t _centralDirectorySize;
74 int64_t _centralDirectoryOffset;
75 OFString *_Nullable _archiveComment;
76#ifdef OF_ZIP_ARCHIVE_M
77@public
78#endif
79 OFMutableArray OF_GENERIC(OFZIPArchiveEntry *) *_entries;
81 *_pathToEntryMap;
82 OFStream *_Nullable _lastReturnedStream;
83}
84
88@property OF_NULLABLE_PROPERTY (assign, nonatomic)
89 OFObject <OFZIPArchiveDelegate> *delegate;
90
94@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *archiveComment;
95
104@property (readonly, nonatomic)
105 OFArray OF_GENERIC(OFZIPArchiveEntry *) *entries;
106
118+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode;
119
130+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode;
131
141+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI;
142
143- (instancetype)init OF_UNAVAILABLE;
144
157- (instancetype)initWithStream: (OFStream *)stream
158 mode: (OFString *)mode OF_DESIGNATED_INITIALIZER;
159
171- (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode;
172
198- (OFStream *)streamForReadingFile: (OFString *)path;
199
234- (OFStream *)streamForWritingEntry: (OFZIPArchiveEntry *)entry;
235
241- (void)close;
242@end
243
244OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition OFArray.h:109
A class for representing IRIs, URIs, URLs and URNs, for parsing them as well as accessing parts of th...
Definition OFIRI.h:41
An abstract class for storing, adding and removing objects in an array.
Definition OFMutableArray.h:48
An abstract class for storing and changing objects in a dictionary.
Definition OFMutableDictionary.h:48
The root class for all other classes inside ObjFW.
Definition OFObject.h:692
A stream that supports seeking.
Definition OFSeekableStream.h:75
A base class for different types of streams.
Definition OFStream.h:280
A class for handling strings.
Definition OFString.h:143
A class which represents an entry in the central directory of a ZIP archive.
Definition OFZIPArchiveEntry.h:111
A class for accessing and manipulating ZIP files.
Definition OFZIPArchive.h:61