ObjFW
Loading...
Searching...
No Matches
OFZooArchive.h
1/*
2 * Copyright (c) 2008-2026 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 "OFSeekableStream.h"
22#import "OFString.h"
23#import "OFZooArchiveEntry.h"
24
25OF_ASSUME_NONNULL_BEGIN
26
27@class OFMutableSet OF_GENERIC(ObjectType);
28@class OFNumber;
29
35OF_SUBCLASSING_RESTRICTED
37{
38 OF_KINDOF(OFStream *) _stream;
39 uint_least8_t _mode;
40 OFStringEncoding _encoding;
41 uint16_t _minVersionNeeded;
42 uint8_t _headerType;
43 OFString *_Nullable _archiveComment;
44 OFZooArchiveEntry *_Nullable _currentEntry;
45#ifdef OF_ZOO_ARCHIVE_M
46@public
47#endif
48 OFStream *_Nullable _lastReturnedStream;
49@protected
50 OFStreamOffset _lastHeaderOffset;
51 OFMutableSet OF_GENERIC(OFNumber *) *_seenHeaderOffsets;
52 size_t _lastHeaderLength;
53}
54
58@property (nonatomic) OFStringEncoding encoding;
59
63@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *archiveComment;
64
75+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode;
76
85+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode;
86
96+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI;
97
98- (instancetype)init OF_UNAVAILABLE;
99
111- (instancetype)initWithStream: (OFStream *)stream
112 mode: (OFString *)mode OF_DESIGNATED_INITIALIZER;
113
123- (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode;
124
144- (nullable OFZooArchiveEntry *)nextEntry;
145
158
182- (OFStream *)streamForWritingEntry: (OFZooArchiveEntry *)entry;
183
189- (void)close;
190@end
191
192OF_ASSUME_NONNULL_END
OFStringEncoding
The encoding of a string.
Definition OFString.h:65
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 a mutable unordered set of unique objects.
Definition OFMutableSet.h:33
Provides a way to store a number in an object.
Definition OFNumber.h:48
The root class for all other classes inside ObjFW.
Definition OFObject.h:962
instancetype init()
Initializes an already allocated object.
Definition OFObject.m:674
id copy()
Returns the class.
Definition OFObject.m:1329
A base class for different types of streams.
Definition OFStream.h:280
A class for handling strings.
Definition OFString.h:144
A class which represents an entry in a Zoo archive.
Definition OFZooArchiveEntry.h:37
A class for accessing and manipulating Zoo files.
Definition OFZooArchive.h:37
nullable OFZooArchiveEntry * nextEntry()
Returns the next entry from the Zoo archive or nil if all entries have been read.
Definition OFZooArchive.m:256
OFString * archiveComment
The archive comment.
Definition OFZooArchive.m:236
OFStream * streamForReadingCurrentEntry()
Returns a stream for reading the current entry.
Definition OFZooArchive.m:293
void close()
Closes the OFZooArchive.
Definition OFZooArchive.m:405
OFStringEncoding encoding
The encoding to use for the archive. Defaults to UTF-8.
Definition OFZooArchive.h:58