ObjFW
OFZIPArchive.h
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 #import "OFString.h"
18 #import "OFZIPArchiveEntry.h"
19 
20 OF_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 OFStream;
26 
32 OF_SUBCLASSING_RESTRICTED
34 {
35  OFStream *_stream;
36  int64_t _offset;
37  enum {
38  OF_ZIP_ARCHIVE_MODE_READ,
39  OF_ZIP_ARCHIVE_MODE_WRITE,
40  OF_ZIP_ARCHIVE_MODE_APPEND
41  } _mode;
42  uint32_t _diskNumber, _centralDirectoryDisk;
43  uint64_t _centralDirectoryEntriesInDisk, _centralDirectoryEntries;
44  uint64_t _centralDirectorySize;
45  int64_t _centralDirectoryOffset;
46  OFString *_Nullable _archiveComment;
47  OFMutableArray OF_GENERIC(OFZIPArchiveEntry *) *_entries;
49  *_pathToEntryMap;
50  OFStream *_Nullable _lastReturnedStream;
51 }
52 
56 @property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *archiveComment;
57 
66 @property (readonly, nonatomic)
68 
79 + (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode;
80 
81 #ifdef OF_HAVE_FILES
91 + (instancetype)archiveWithPath: (OFString *)path mode: (OFString *)mode;
92 #endif
93 
94 - (instancetype)init OF_UNAVAILABLE;
95 
107 - (instancetype)initWithStream: (OFStream *)stream
108  mode: (OFString *)mode OF_DESIGNATED_INITIALIZER;
109 
110 #ifdef OF_HAVE_FILES
121 - (instancetype)initWithPath: (OFString *)path mode: (OFString *)mode;
122 #endif
123 
141 - (OFStream *)streamForReadingFile: (OFString *)path;
142 
167 - (OFStream *)streamForWritingEntry: (OFZIPArchiveEntry *)entry;
168 
172 - (void)close;
173 @end
174 
175 OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition: OFArray.h:92
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:520
A base class for different types of streams.
Definition: OFStream.h:191
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 class for accessing and manipulating ZIP files.
Definition: OFZIPArchive.h:34
OFArray * entries
The entries in the central directory of the archive as an array of objects of class OFZIPArchiveEntry...
Definition: OFZIPArchive.h:67
OFString * archiveComment
The archive comment.
Definition: OFZIPArchive.h:56