|
|
|
@@ -41,93 +41,560 @@
|
|
|
|
|
@class OZZipWriteStream;
|
|
|
|
|
@class OZFileInZipInfo;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief OZZipFile provides read or write access to a single zip file.
|
|
|
|
|
<p> During initialization you must specify the access mode, i.e. if the zip
|
|
|
|
|
file is being created, appended, or unzipped. You can also specify if the zip
|
|
|
|
|
file must be opened in legacy 32-bit mode, to be compatible with older
|
|
|
|
|
operating systems (such as some versions of Android).</p>
|
|
|
|
|
<p> If the zip file has been opened in unzip mode, you can list its content,
|
|
|
|
|
move within its content from file to file, and finally open a reading stream
|
|
|
|
|
of the selected file.</p>
|
|
|
|
|
<p> If the zip file has been opened in creation or append mode, you can open a
|
|
|
|
|
writing stream to add new files to its content.</p>
|
|
|
|
|
*/
|
|
|
|
|
@interface OZZipFile : NSObject
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
#pragma mark Initialization
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a OZZipFile with the specified zip file name and access mode.
|
|
|
|
|
<p>The access mode specifies if the zip is being created, appended, or
|
|
|
|
|
unzipped.</p>
|
|
|
|
|
<p>Note: the zip file is opened in 64-bit mode.</p>
|
|
|
|
|
@param fileName File name of the zip file.
|
|
|
|
|
@param mode Access mode, can be:<ul>
|
|
|
|
|
<li>OZZipFileModeUnzip: the zip file is opened for reading.
|
|
|
|
|
<li>OZZipFileModeCreate: the zip file is opened for creation.
|
|
|
|
|
<br/>Note: if the file already exists the behavior is unspecified.
|
|
|
|
|
<li>OZZipFileModeAppend: the zip file is opened for writing.
|
|
|
|
|
</ul>
|
|
|
|
|
@throws OZZipException If the file can't be opened due to an erroror if the
|
|
|
|
|
access mode is invalid.
|
|
|
|
|
*/
|
|
|
|
|
- (nonnull instancetype) initWithFileName:(nonnull NSString *)fileName mode:(OZZipFileMode)mode;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a OZZipFile with the specified zip file name, access mode and
|
|
|
|
|
legacy 32-bit mode compatibility.
|
|
|
|
|
<p>The access mode specifies if the zip is being created, appended, or
|
|
|
|
|
unzipped.</p>
|
|
|
|
|
@param fileName File name of the zip file.
|
|
|
|
|
@param mode Access mode, can be:<ul>
|
|
|
|
|
<li>OZZipFileModeUnzip: the zip file is opened for reading.
|
|
|
|
|
<li>OZZipFileModeCreate: the zip file is opened for creation.
|
|
|
|
|
<br/>Note: if the file already exists the behavior is unspecified.
|
|
|
|
|
<li>OZZipFileModeAppend: the zip file is opened for writing.
|
|
|
|
|
</ul>
|
|
|
|
|
@param legacy32BitMode If set, the zip file is opened in 32-bit mode to
|
|
|
|
|
provide compatibility with older operating systems (such as some
|
|
|
|
|
version of Android).
|
|
|
|
|
@throws OZZipException If the file can't be opened due to an error or if the
|
|
|
|
|
access mode is invalid.
|
|
|
|
|
*/
|
|
|
|
|
- (nonnull instancetype) initWithFileName:(nonnull NSString *)fileName mode:(OZZipFileMode)mode legacy32BitMode:(BOOL)legacy32BitMode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
#pragma mark Initialization (NSError variants)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a OZZipFile with the specified zip file name and access mode.
|
|
|
|
|
<p>The access mode specifies if the zip is being created, appended, or
|
|
|
|
|
unzipped.</p>
|
|
|
|
|
<p>Note: the zip file is opened in 64-bit mode.</p>
|
|
|
|
|
@param fileName File name of the zip file.
|
|
|
|
|
@param mode Access mode, can be:<ul>
|
|
|
|
|
<li>OZZipFileModeUnzip: the zip file is opened for reading.
|
|
|
|
|
<li>OZZipFileModeCreate: the zip file is opened for creation.
|
|
|
|
|
<br/>Note: if the file already exists the behavior is unspecified.
|
|
|
|
|
<li>OZZipFileModeAppend: the zip file is opened for writing.
|
|
|
|
|
</ul>
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the file
|
|
|
|
|
can't be opened.
|
|
|
|
|
@throws OZZipException If the access mode is invalid.
|
|
|
|
|
*/
|
|
|
|
|
- (nullable instancetype) initWithFileName:(nonnull NSString *)fileName mode:(OZZipFileMode)mode error:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a OZZipFile with the specified zip file name, access mode and
|
|
|
|
|
legacy 32-bit mode compatibility.
|
|
|
|
|
<p>The access mode specifies if the zip is being created, appended, or
|
|
|
|
|
unzipped.</p>
|
|
|
|
|
@param fileName File name of the zip file.
|
|
|
|
|
@param mode Access mode, can be:<ul>
|
|
|
|
|
<li>OZZipFileModeUnzip: the zip file is opened for reading.
|
|
|
|
|
<li>OZZipFileModeCreate: the zip file is opened for creation.
|
|
|
|
|
<br/>Note: if the file already exists the behavior is unspecified.
|
|
|
|
|
<li>OZZipFileModeAppend: the zip file is opened for writing.
|
|
|
|
|
</ul>
|
|
|
|
|
@param legacy32BitMode If set, the zip file is opened in 32-bit mode to
|
|
|
|
|
provide compatibility with older operating systems (such as some
|
|
|
|
|
version of Android).
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the file
|
|
|
|
|
can't be opened.
|
|
|
|
|
@throws OZZipException If the access mode is invalid.
|
|
|
|
|
*/
|
|
|
|
|
- (nullable instancetype) initWithFileName:(nonnull NSString *)fileName mode:(OZZipFileMode)mode legacy32BitMode:(BOOL)legacy32BitMode error:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
#pragma mark File writing
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a new OZZipWriteStream for adding a new file in the zip file
|
|
|
|
|
content.
|
|
|
|
|
<p>The returned write stream can be used to write data to the new file.</p>
|
|
|
|
|
<p>Note: the new file is added with the current date/time.</p>
|
|
|
|
|
@param fileNameInZip Name of the new file that must be added to the zip file
|
|
|
|
|
content.
|
|
|
|
|
<br/>Note: to structure the zip file with directories and subdirectories,
|
|
|
|
|
ensure to prepend them in the file name, e.g. "docs/html/index.html"
|
|
|
|
|
@param compressionLevel The compression level that must be used to compress
|
|
|
|
|
the new file added to the zip file content. Can be:<ul>
|
|
|
|
|
<li>OZZipCompressionLevelNone: does not compress the new file, it is stored
|
|
|
|
|
as is.
|
|
|
|
|
<li>OZZipCompressionLevelFastest: uses the fastest compression level, which
|
|
|
|
|
also compresses the least.
|
|
|
|
|
<li>OZZipCompressionLevelBest: uses the best compression level, which is also
|
|
|
|
|
the slowest.
|
|
|
|
|
<li>OZZipCompressionLevelDefault: uses the default compression level,
|
|
|
|
|
somewhere inbetween OZZipCompressionLevelBest and
|
|
|
|
|
OZZipCompressionLevelFastest.
|
|
|
|
|
</ul>
|
|
|
|
|
@return A new OZZipWriteStream for writing data to the new file in the zip
|
|
|
|
|
file content.
|
|
|
|
|
@throws OZZipException If the file stream can't be created due to an error or
|
|
|
|
|
if the zip file has been opened in unzip mode.
|
|
|
|
|
*/
|
|
|
|
|
- (nonnull OZZipWriteStream *) writeFileInZipWithName:(nonnull NSString *)fileNameInZip compressionLevel:(OZZipCompressionLevel)compressionLevel;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a new OZZipWriteStream for adding a new file in the zip file
|
|
|
|
|
content.
|
|
|
|
|
<p>The returned write stream can be used to write data to the new file.</p>
|
|
|
|
|
@param fileNameInZip Name of the new file that must be added to the zip file
|
|
|
|
|
content.
|
|
|
|
|
<br/>Note: to structure the zip file with directories and subdirectories,
|
|
|
|
|
ensure to prepend them in the file name, e.g. "docs/html/index.html"
|
|
|
|
|
@param fileDate The date/time of the new file that must be added to the zip
|
|
|
|
|
file content.
|
|
|
|
|
@param compressionLevel The compression level that must be used to compress
|
|
|
|
|
the new file added to the zip file content. Can be:<ul>
|
|
|
|
|
<li>OZZipCompressionLevelNone: does not compress the new file, it is stored
|
|
|
|
|
as is.
|
|
|
|
|
<li>OZZipCompressionLevelFastest: uses the fastest compression level, which
|
|
|
|
|
also compresses the least.
|
|
|
|
|
<li>OZZipCompressionLevelBest: uses the best compression level, which is also
|
|
|
|
|
the slowest.
|
|
|
|
|
<li>OZZipCompressionLevelDefault: uses the default compression level,
|
|
|
|
|
somewhere inbetween OZZipCompressionLevelBest and
|
|
|
|
|
OZZipCompressionLevelFastest.
|
|
|
|
|
</ul>
|
|
|
|
|
@return A new OZZipWriteStream for writing data to the new file in the zip
|
|
|
|
|
file content.
|
|
|
|
|
@throws OZZipException If the file stream can't be created due to an error or
|
|
|
|
|
if the zip file has been opened in unzip mode.
|
|
|
|
|
*/
|
|
|
|
|
- (nonnull OZZipWriteStream *) writeFileInZipWithName:(nonnull NSString *)fileNameInZip fileDate:(nonnull NSDate *)fileDate compressionLevel:(OZZipCompressionLevel)compressionLevel;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a new OZZipWriteStream for adding a new encrypted file in the
|
|
|
|
|
zip file content.
|
|
|
|
|
<p>The returned write stream can be used to write data to the new file.</p>
|
|
|
|
|
@param fileNameInZip Name of the new file that must be added to the zip file
|
|
|
|
|
content.
|
|
|
|
|
<br/>Note: to structure the zip file with directories and subdirectories,
|
|
|
|
|
ensure to prepend them in the file name, e.g. "docs/html/index.html"
|
|
|
|
|
@param fileDate The date/time of the new file that must be added to the zip
|
|
|
|
|
file content.
|
|
|
|
|
@param compressionLevel The compression level that must be used to compress
|
|
|
|
|
the new file added to the zip file content. Can be:<ul>
|
|
|
|
|
<li>OZZipCompressionLevelNone: does not compress the new file, it is stored
|
|
|
|
|
as is.
|
|
|
|
|
<li>OZZipCompressionLevelFastest: uses the fastest compression level, which
|
|
|
|
|
also compresses the least.
|
|
|
|
|
<li>OZZipCompressionLevelBest: uses the best compression level, which is also
|
|
|
|
|
the slowest.
|
|
|
|
|
<li>OZZipCompressionLevelDefault: uses the default compression level,
|
|
|
|
|
somewhere inbetween OZZipCompressionLevelBest and
|
|
|
|
|
OZZipCompressionLevelFastest.
|
|
|
|
|
</ul>
|
|
|
|
|
@param password The password that must be used to encrypt the new file data.
|
|
|
|
|
@param crc32 A precomputed CRC32 of the new file data (needed for crypting).
|
|
|
|
|
@return A new OZZipWriteStream for writing data to the new file in the zip
|
|
|
|
|
file content.
|
|
|
|
|
@throws OZZipException If the file stream can't be created due to an error or
|
|
|
|
|
if the zip file has been opened in unzip mode.
|
|
|
|
|
*/
|
|
|
|
|
- (nonnull OZZipWriteStream *) writeFileInZipWithName:(nonnull NSString *)fileNameInZip fileDate:(nonnull NSDate *)fileDate compressionLevel:(OZZipCompressionLevel)compressionLevel password:(nonnull NSString *)password crc32:(NSUInteger)crc32;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
#pragma mark File writing (NSError variants)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a new OZZipWriteStream for adding a new file in the zip file
|
|
|
|
|
content.
|
|
|
|
|
<p>The returned write stream can be used to write data to the new file.</p>
|
|
|
|
|
<p>Note: the new file is added with the current date/time.</p>
|
|
|
|
|
@param fileNameInZip Name of the new file that must be added to the zip file
|
|
|
|
|
content.
|
|
|
|
|
<br/>Note: to structure the zip file with directories and subdirectories,
|
|
|
|
|
ensure to prepend them in the file name, e.g. "docs/html/index.html"
|
|
|
|
|
@param compressionLevel The compression level that must be used to compress
|
|
|
|
|
the new file added to the zip file content. Can be:<ul>
|
|
|
|
|
<li>OZZipCompressionLevelNone: does not compress the new file, it is stored
|
|
|
|
|
as is.
|
|
|
|
|
<li>OZZipCompressionLevelFastest: uses the fastest compression level, which
|
|
|
|
|
also compresses the least.
|
|
|
|
|
<li>OZZipCompressionLevelBest: uses the best compression level, which is also
|
|
|
|
|
the slowest.
|
|
|
|
|
<li>OZZipCompressionLevelDefault: uses the default compression level,
|
|
|
|
|
somewhere inbetween OZZipCompressionLevelBest and
|
|
|
|
|
OZZipCompressionLevelFastest.
|
|
|
|
|
</ul>
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the write
|
|
|
|
|
stream can't be opened.
|
|
|
|
|
@return A new OZZipWriteStream for writing data to the new file in the zip
|
|
|
|
|
file content, or <code>nil</code> if an error occurs.
|
|
|
|
|
@throws OZZipException If the zip file has been opened in unzip mode.
|
|
|
|
|
*/
|
|
|
|
|
- (nullable OZZipWriteStream *) writeFileInZipWithName:(nonnull NSString *)fileNameInZip compressionLevel:(OZZipCompressionLevel)compressionLevel error:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a new OZZipWriteStream for adding a new file in the zip file
|
|
|
|
|
content.
|
|
|
|
|
<p>The returned write stream can be used to write data to the new file.</p>
|
|
|
|
|
@param fileNameInZip Name of the new file that must be added to the zip file
|
|
|
|
|
content.
|
|
|
|
|
<br/>Note: to structure the zip file with directories and subdirectories,
|
|
|
|
|
ensure to prepend them in the file name, e.g. "docs/html/index.html"
|
|
|
|
|
@param fileDate The date/time of the new file that must be added to the zip
|
|
|
|
|
file content.
|
|
|
|
|
@param compressionLevel The compression level that must be used to compress
|
|
|
|
|
the new file added to the zip file content. Can be:<ul>
|
|
|
|
|
<li>OZZipCompressionLevelNone: does not compress the new file, it is stored
|
|
|
|
|
as is.
|
|
|
|
|
<li>OZZipCompressionLevelFastest: uses the fastest compression level, which
|
|
|
|
|
also compresses the least.
|
|
|
|
|
<li>OZZipCompressionLevelBest: uses the best compression level, which is also
|
|
|
|
|
the slowest.
|
|
|
|
|
<li>OZZipCompressionLevelDefault: uses the default compression level,
|
|
|
|
|
somewhere inbetween OZZipCompressionLevelBest and
|
|
|
|
|
OZZipCompressionLevelFastest.
|
|
|
|
|
</ul>
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the write
|
|
|
|
|
stream can't be opened.
|
|
|
|
|
@return A new OZZipWriteStream for writing data to the new file in the zip
|
|
|
|
|
file content, or <code>nil</code> if an error occurs.
|
|
|
|
|
@throws OZZipException If the zip file has been opened in unzip mode.
|
|
|
|
|
*/
|
|
|
|
|
- (nullable OZZipWriteStream *) writeFileInZipWithName:(nonnull NSString *)fileNameInZip fileDate:(nonnull NSDate *)fileDate compressionLevel:(OZZipCompressionLevel)compressionLevel error:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a new OZZipWriteStream for adding a new encrypted file in the
|
|
|
|
|
zip file content.
|
|
|
|
|
<p>The returned write stream can be used to write data to the new file.</p>
|
|
|
|
|
@param fileNameInZip Name of the new file that must be added to the zip file
|
|
|
|
|
content.
|
|
|
|
|
<br/>Note: to structure the zip file with directories and subdirectories,
|
|
|
|
|
ensure to prepend them in the file name, e.g. "docs/html/index.html"
|
|
|
|
|
@param fileDate The date/time of the new file that must be added to the zip
|
|
|
|
|
file content.
|
|
|
|
|
@param compressionLevel The compression level that must be used to compress
|
|
|
|
|
the new file added to the zip file content. Can be:<ul>
|
|
|
|
|
<li>OZZipCompressionLevelNone: does not compress the new file, it is stored
|
|
|
|
|
as is.
|
|
|
|
|
<li>OZZipCompressionLevelFastest: uses the fastest compression level, which
|
|
|
|
|
also compresses the least.
|
|
|
|
|
<li>OZZipCompressionLevelBest: uses the best compression level, which is also
|
|
|
|
|
the slowest.
|
|
|
|
|
<li>OZZipCompressionLevelDefault: uses the default compression level,
|
|
|
|
|
somewhere inbetween OZZipCompressionLevelBest and
|
|
|
|
|
OZZipCompressionLevelFastest.
|
|
|
|
|
</ul>
|
|
|
|
|
@param password The password that must be used to encrypt the new file data.
|
|
|
|
|
@param crc32 A precomputed CRC32 of the new file data (needed for crypting).
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the write
|
|
|
|
|
stream can't be opened.
|
|
|
|
|
@return A new OZZipWriteStream for writing data to the new file in the zip
|
|
|
|
|
file content, or <code>nil</code> if an error occurs.
|
|
|
|
|
@throws OZZipException If the zip file has been opened in unzip mode.
|
|
|
|
|
*/
|
|
|
|
|
- (nullable OZZipWriteStream *) writeFileInZipWithName:(nonnull NSString *)fileNameInZip fileDate:(nonnull NSDate *)fileDate compressionLevel:(OZZipCompressionLevel)compressionLevel password:(nonnull NSString *)password crc32:(NSUInteger)crc32 error:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
#pragma mark File seeking and info
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Moves selection to the first file contained in the zip file.
|
|
|
|
|
<p>The selected file may then be read by obaining a OZZipReadStream with
|
|
|
|
|
<code>readCurrentFileInZip</code>.</p>
|
|
|
|
|
@throws OZZipException If the first file can't be selected due to an error or
|
|
|
|
|
if the zip file has been opened with a mode other than Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (void) goToFirstFileInZip;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Moves selection to the next file contained in the zip file.
|
|
|
|
|
<p>The selected file may then be read by obaining a OZZipReadStream with
|
|
|
|
|
<code>readCurrentFileInZip</code>.</p>
|
|
|
|
|
@return <code>YES</code> if the next file has been selected,
|
|
|
|
|
<code>NO</code> if there were no more files to select in the zip file.
|
|
|
|
|
@throws OZZipException If the next file can't be selected due to an error or
|
|
|
|
|
if the zip file has been opened with a mode other than Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (BOOL) goToNextFileInZip;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Locates a file by name in the zip file and selects it.
|
|
|
|
|
<p>The selected file may then be read by obaining a OZZipReadStream with
|
|
|
|
|
<code>readCurrentFileInZip</code>.</p>
|
|
|
|
|
@return <code>YES</code> if the file has been located and selected,
|
|
|
|
|
<code>NO</code> if the specified file name is not present in the zip file.
|
|
|
|
|
@throws OZZipException If the file can't be located due to an error or if the
|
|
|
|
|
zip file has been opened with a mode other than Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (BOOL) locateFileInZip:(nonnull NSString *)fileNameInZip;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Returns the number of files contained in the zip file.
|
|
|
|
|
@return The number of files contained in the zip file.
|
|
|
|
|
@throws OZZipException If the number of files could not be obtained due to an
|
|
|
|
|
error or if the zip file has been opened with a mode other than Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (NSUInteger) numFilesInZip;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Returns a list of OZFileInZipInfo with the information on all the files
|
|
|
|
|
contained in the zip file.
|
|
|
|
|
@return The list of OZFileInZipInfo with the information on all the files
|
|
|
|
|
contained in the zip file.
|
|
|
|
|
@throws OZZipException If the list of file info could not be obtained due to
|
|
|
|
|
an error or if the zip file has been opened with a mode other than Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (nonnull NSArray *) listFileInZipInfos;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Returns an OZFileInZipInfo with the information on the currently
|
|
|
|
|
selected file in the zip file.
|
|
|
|
|
@return An OZFileInZipInfo with the information on the currently
|
|
|
|
|
selected file in the zip file.
|
|
|
|
|
@throws OZZipException If the info info could not be obtained due to an error
|
|
|
|
|
or if the zip file has been opened with a mode other than Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (nonnull OZFileInZipInfo *) getCurrentFileInZipInfo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
#pragma mark File seeking and info (NSError variants)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Moves selection to the first file contained in the zip file.
|
|
|
|
|
<p>The selected file may then be read by obaining a OZZipReadStream with
|
|
|
|
|
<code>readCurrentFileInZip</code>.</p>
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the first file
|
|
|
|
|
can't be selected.
|
|
|
|
|
@return <code>YES</code> if the first file has been selected, <code>NO</code>
|
|
|
|
|
if it could not select the first file due to an error.
|
|
|
|
|
@throws OZZipException If the zip file has been opened with a mode other than
|
|
|
|
|
Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (BOOL) goToFirstFileInZipWithError:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Moves selection to the next file contained in the zip file.
|
|
|
|
|
<p>The selected file may then be read by obaining a OZZipReadStream with
|
|
|
|
|
<code>readCurrentFileInZip</code>.</p>
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the next file
|
|
|
|
|
can't be selected.
|
|
|
|
|
@return <code>YES</code> if the next file has been selected, <code>NO</code>
|
|
|
|
|
if there were no more files to select in the zip file, or the next file could
|
|
|
|
|
not be selected due to an error.
|
|
|
|
|
@throws OZZipException If the zip file has been opened with a mode other than
|
|
|
|
|
Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (BOOL) goToNextFileInZipWithError:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Locates a file by name in the zip file and selects it.
|
|
|
|
|
<p>The selected file may then be read by obaining a OZZipReadStream with
|
|
|
|
|
<code>readCurrentFileInZip</code>.</p>
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the file can't
|
|
|
|
|
be located.
|
|
|
|
|
@return <code>YES</code> if the file has been located and selected,
|
|
|
|
|
<code>NO</code> if the specified file name is not present in the zip file or
|
|
|
|
|
the file could not be located due to an error.
|
|
|
|
|
@throws OZZipException If the zip file has been opened with a mode other than
|
|
|
|
|
Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (BOOL) locateFileInZip:(nonnull NSString *)fileNameInZip error:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Returns the number of files contained in the zip file.
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the number of
|
|
|
|
|
files could not be obtained.
|
|
|
|
|
@return The number of files contained in the zip file, 0 if the number of
|
|
|
|
|
files could not be obtained due to an error.
|
|
|
|
|
@throws OZZipException If the zip file has been opened with a mode other
|
|
|
|
|
than Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (NSUInteger) numFilesInZipWithError:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Returns a list of OZFileInZipInfo with the information on all the files
|
|
|
|
|
contained in the zip file.
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the list of
|
|
|
|
|
file info could not be obtained.
|
|
|
|
|
@return The list of OZFileInZipInfo with the information on all the files
|
|
|
|
|
contained in the zip file, <code>nil</code> if the list of file info could
|
|
|
|
|
not be obtained due to an error.
|
|
|
|
|
@throws OZZipException If the zip file has been opened with a mode other than
|
|
|
|
|
Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (nullable NSArray *) listFileInZipInfosWithError:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Returns an OZFileInZipInfo with the information on the currently
|
|
|
|
|
selected file in the zip file.
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the file info
|
|
|
|
|
could not be obtained.
|
|
|
|
|
@return An OZFileInZipInfo with the information on the currently
|
|
|
|
|
selected file in the zip file, <code>nil</code> if the file info could not be
|
|
|
|
|
obtained due to an error.
|
|
|
|
|
@throws OZZipException If the zip file has been opened with a mode other than
|
|
|
|
|
Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (nullable OZFileInZipInfo *) getCurrentFileInZipInfoWithError:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
#pragma mark File reading
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a OZZipReadStream for reading the currently selected file in
|
|
|
|
|
the zip file.
|
|
|
|
|
<p>A file in the zip file can be selected using
|
|
|
|
|
<code>goToFirstFileInZip</code>, <code>goToNextFileInZip</code> and
|
|
|
|
|
<code>locateFileInZip:</code>.</p>
|
|
|
|
|
@return The OZZipReadStream to be used for reading the currently selected file
|
|
|
|
|
in the zip file.
|
|
|
|
|
@throws OZZipException If the read stream could not be created due to an error
|
|
|
|
|
or if the zip file has been opened with a mode other than Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (nonnull OZZipReadStream *) readCurrentFileInZip;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a OZZipReadStream for reading the currently selected file in
|
|
|
|
|
the zip file, if it is encrypted.
|
|
|
|
|
<p>A file in the zip file can be selected using
|
|
|
|
|
<code>goToFirstFileInZip</code>, <code>goToNextFileInZip</code> and
|
|
|
|
|
<code>locateFileInZip:</code>.</p>
|
|
|
|
|
@param password The password that must be used to decrypt the file data.
|
|
|
|
|
@return The OZZipReadStream to be used for reading the currently selected file
|
|
|
|
|
in the zip file.
|
|
|
|
|
@throws OZZipException If the read stream could not be created due to an error
|
|
|
|
|
or if the zip file has been opened with a mode other than Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (nonnull OZZipReadStream *) readCurrentFileInZipWithPassword:(nonnull NSString *)password;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
#pragma mark File reading (NSError variants)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a OZZipReadStream for reading the currently selected file in
|
|
|
|
|
the zip file.
|
|
|
|
|
<p>A file in the zip file can be selected using
|
|
|
|
|
<code>goToFirstFileInZip</code>, <code>goToNextFileInZip</code> and
|
|
|
|
|
<code>locateFileInZip:</code>.</p>
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the read stream
|
|
|
|
|
could not be created.
|
|
|
|
|
@return The OZZipReadStream to be used for reading the currently selected file
|
|
|
|
|
in the zip file, <code>nil</code> if the read stream could not be created
|
|
|
|
|
due to an error.
|
|
|
|
|
@throws OZZipException If the zip file has been opened with a mode other than
|
|
|
|
|
Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (nullable OZZipReadStream *) readCurrentFileInZipWithError:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Creates a OZZipReadStream for reading the currently selected file in
|
|
|
|
|
the zip file, if it is encrypted.
|
|
|
|
|
<p>A file in the zip file can be selected using
|
|
|
|
|
<code>goToFirstFileInZip</code>, <code>goToNextFileInZip</code> and
|
|
|
|
|
<code>locateFileInZip:</code>.</p>
|
|
|
|
|
@param password The password that must be used to decrypt the file data.
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the read stream
|
|
|
|
|
could not be created.
|
|
|
|
|
@return The OZZipReadStream to be used for reading the currently selected file
|
|
|
|
|
in the zip file, <code>nil</code> if the read stream could not be created
|
|
|
|
|
due to an error.
|
|
|
|
|
@throws OZZipException If the zip file has been opened with a mode other than
|
|
|
|
|
Unzip.
|
|
|
|
|
*/
|
|
|
|
|
- (nullable OZZipReadStream *) readCurrentFileInZipWithPassword:(nonnull NSString *)password error:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
#pragma mark Closing
|
|
|
|
|
|
|
|
|
|
- (BOOL) close;
|
|
|
|
|
/**
|
|
|
|
|
@brief Closes the zip file and releases its resources.
|
|
|
|
|
<p>Once you have finished working with the zip file (e.g. all files have been
|
|
|
|
|
unzipped, or all files have been added), it is important to close it so system
|
|
|
|
|
resources may be freed.</p>
|
|
|
|
|
<p>Note: after the zip file has been closed any subsequent call will result in an
|
|
|
|
|
error.</p>
|
|
|
|
|
@throws OZZipException If the zip file could not be closed due to an error.
|
|
|
|
|
*/
|
|
|
|
|
- (void) close;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
#pragma mark Closing (NSError variants)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Closes the zip file and releases its resources.
|
|
|
|
|
<p>Once you have finished working with the zip file (e.g. all files have been
|
|
|
|
|
unzipped, or all files have been added), it is important to close it so system
|
|
|
|
|
resources may be freed.</p>
|
|
|
|
|
<p>Note: after the zip file has been closed any subsequent call will result in an
|
|
|
|
|
error.</p>
|
|
|
|
|
@param error If passed, may be filled with an NSError is case the zip file
|
|
|
|
|
could not be closed.
|
|
|
|
|
@return <code>YES</code> if the zip file has been closed, <code>NO</code> if
|
|
|
|
|
the zip file could not be closed due to an error.
|
|
|
|
|
*/
|
|
|
|
|
- (BOOL) closeWithError:(NSError * __autoreleasing __nullable * __nullable)error;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
#pragma mark Properties
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief File name of the zip file.
|
|
|
|
|
*/
|
|
|
|
|
@property (nonatomic, readonly, nonnull) NSString *fileName;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief Access mode specified during opening. Can be:<ul>
|
|
|
|
|
<li>OZZipFileModeUnzip: the zip file has been opened for reading.
|
|
|
|
|
<li>OZZipFileModeCreate: the zip file has been opened for creation.
|
|
|
|
|
<li>OZZipFileModeAppend: the zip file has been opened for writing.
|
|
|
|
|
</ul>
|
|
|
|
|
*/
|
|
|
|
|
@property (nonatomic, readonly) OZZipFileMode mode;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@brief <code>YES</code> if the zip file has been opened in 32-bit
|
|
|
|
|
compatibility mode, <code>NO</code> if it has been opened in standard
|
|
|
|
|
(default) 64-bit mode.
|
|
|
|
|
*/
|
|
|
|
|
@property (nonatomic, readonly) BOOL legacy32BitMode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|