1
2
3
4
5
6
7
8
9
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
|
|
1
2
3
4
5
6
7
8
9
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
|
︙ | | | ︙ | |
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
* @class OFZIPArchive OFZIPArchive.h ObjFW/OFZIPArchive.h
*
* @brief A class for accessing and manipulating ZIP files.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFZIPArchive: OFObject
{
OFStream *_stream;
#ifdef OF_ZIP_ARCHIVE_M
@public
#endif
int64_t _offset;
@protected
uint_least8_t _mode;
uint32_t _diskNumber, _centralDirectoryDisk;
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
* @class OFZIPArchive OFZIPArchive.h ObjFW/OFZIPArchive.h
*
* @brief A class for accessing and manipulating ZIP files.
*/
OF_SUBCLASSING_RESTRICTED
@interface OFZIPArchive: OFObject
{
OF_KINDOF(OFStream *) _stream;
#ifdef OF_ZIP_ARCHIVE_M
@public
#endif
int64_t _offset;
@protected
uint_least8_t _mode;
uint32_t _diskNumber, _centralDirectoryDisk;
|
︙ | | | ︙ | |
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
* @throw OFInvalidFormatException The format is not that of a valid ZIP archive
*/
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode;
/**
* @brief Creates a new OFZIPArchive object with the specified file.
*
* @param URI The URI to the ZIP file
* @param mode The mode for the ZIP file. Valid modes are "r" for reading,
* "w" for creating a new file and "a" for appending to an existing
* archive.
* @return A new, autoreleased OFZIPArchive
* @throw OFInvalidFormatException The format is not that of a valid ZIP archive
*/
+ (instancetype)archiveWithURI: (OFURI *)URI mode: (OFString *)mode;
/**
* @brief Creates a URI for accessing a the specified file within the specified
* ZIP archive.
*
* @param path The path of the file within the archive
* @param URI The URI of the archive
* @return A URI for accessing the specified file within the specified ZIP
* archive
*/
+ (OFURI *)URIForFilePath: (OFString *)path inArchiveWithURI: (OFURI *)URI;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OFZIPArchive object with the
* specified stream.
*
|
|
|
|
|
|
|
|
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
* @throw OFInvalidFormatException The format is not that of a valid ZIP archive
*/
+ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode;
/**
* @brief Creates a new OFZIPArchive object with the specified file.
*
* @param IRI The IRI to the ZIP file
* @param mode The mode for the ZIP file. Valid modes are "r" for reading,
* "w" for creating a new file and "a" for appending to an existing
* archive.
* @return A new, autoreleased OFZIPArchive
* @throw OFInvalidFormatException The format is not that of a valid ZIP archive
*/
+ (instancetype)archiveWithIRI: (OFIRI *)IRI mode: (OFString *)mode;
/**
* @brief Creates an IRI for accessing a the specified file within the
* specified ZIP archive.
*
* @param path The path of the file within the archive
* @param IRI The IRI of the archive
* @return An IRI for accessing the specified file within the specified ZIP
* archive
*/
+ (OFIRI *)IRIForFilePath: (OFString *)path inArchiveWithIRI: (OFIRI *)IRI;
- (instancetype)init OF_UNAVAILABLE;
/**
* @brief Initializes an already allocated OFZIPArchive object with the
* specified stream.
*
|
︙ | | | ︙ | |
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
- (instancetype)initWithStream: (OFStream *)stream
mode: (OFString *)mode OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated OFZIPArchive object with the
* specified file.
*
* @param URI The URI to the ZIP file
* @param mode The mode for the ZIP file. Valid modes are "r" for reading,
* "w" for creating a new file and "a" for appending to an existing
* archive.
* @return An initialized OFZIPArchive
* @throw OFInvalidFormatException The format is not that of a valid ZIP archive
*/
- (instancetype)initWithURI: (OFURI *)URI mode: (OFString *)mode;
/**
* @brief Returns a stream for reading the specified file from the archive.
*
* @note This method is only available in read mode.
*
* @note The returned stream conforms to @ref OFReadyForReadingObserving if the
|
|
|
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
- (instancetype)initWithStream: (OFStream *)stream
mode: (OFString *)mode OF_DESIGNATED_INITIALIZER;
/**
* @brief Initializes an already allocated OFZIPArchive object with the
* specified file.
*
* @param IRI The IRI to the ZIP file
* @param mode The mode for the ZIP file. Valid modes are "r" for reading,
* "w" for creating a new file and "a" for appending to an existing
* archive.
* @return An initialized OFZIPArchive
* @throw OFInvalidFormatException The format is not that of a valid ZIP archive
*/
- (instancetype)initWithIRI: (OFIRI *)IRI mode: (OFString *)mode;
/**
* @brief Returns a stream for reading the specified file from the archive.
*
* @note This method is only available in read mode.
*
* @note The returned stream conforms to @ref OFReadyForReadingObserving if the
|
︙ | | | ︙ | |
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
* * The uncompressed size.
* * The CRC32.
* * Bit 3 and 11 of the general purpose bit flag.
* @return A stream for writing the specified entry to the archive
* @throw OFNotOpenException The archive is not open
* @throw OFInvalidArgumentException The archive is not in write mode
* @throw OFOpenItemFailedException Opening the specified file within the
* archive failed. If @ref errNo is `EEXIST`,
* because there is already a file with the
* same name in the archive.
* @throw OFNotImplementedException The desired compression method is not
* implemented
*/
- (OFStream *)streamForWritingEntry: (OFZIPArchiveEntry *)entry;
/**
* @brief Closes the OFZIPArchive.
|
|
>
>
|
|
|
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
* * The uncompressed size.
* * The CRC32.
* * Bit 3 and 11 of the general purpose bit flag.
* @return A stream for writing the specified entry to the archive
* @throw OFNotOpenException The archive is not open
* @throw OFInvalidArgumentException The archive is not in write mode
* @throw OFOpenItemFailedException Opening the specified file within the
* archive failed. If
* @ref OFOpenItemFailedException#errNo is
* `EEXIST`, it failed because there is
* already a file with the same name in the
* archive.
* @throw OFNotImplementedException The desired compression method is not
* implemented
*/
- (OFStream *)streamForWritingEntry: (OFZIPArchiveEntry *)entry;
/**
* @brief Closes the OFZIPArchive.
|
︙ | | | ︙ | |