ObjFW
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 
25 OF_ASSUME_NONNULL_BEGIN
26 
27 @class OFMutableSet OF_GENERIC(ObjectType);
28 @class OFNumber;
29 
35 OF_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 
157 - (OFStream *)streamForReadingCurrentEntry;
158 
182 - (OFStream *)streamForWritingEntry: (OFZooArchiveEntry *)entry;
183 
189 - (void)close;
190 @end
191 
192 OF_ASSUME_NONNULL_END
OFStringEncoding
The encoding of a string.
Definition: OFString.h:65
The root class for all other classes inside ObjFW.
Definition: OFObject.h:960
A class for accessing and manipulating Zoo files.
Definition: OFZooArchive.h:36
A base class for different types of streams.
Definition: OFStream.h:278
A class which represents an entry in a Zoo archive.
Definition: OFZooArchiveEntry.h:34
An abstract class for a mutable unordered set of unique objects.
Definition: OFMutableSet.h:32
A class for handling strings.
Definition: OFString.h:142
Provides a way to store a number in an object.
Definition: OFNumber.h:46
A class for representing IRIs, URIs, URLs and URNs, for parsing them as well as accessing parts of th...
Definition: OFIRI.h:39