diff --git a/Source/UZKArchive.h b/Source/UZKArchive.h index ce99538..2f54582 100644 --- a/Source/UZKArchive.h +++ b/Source/UZKArchive.h @@ -178,45 +178,6 @@ extern NSString *UZKErrorDomain; @property(nullable, strong) NSProgress *progress; -/** - * DEPRECATED: Creates and returns an archive at the given path - * - * @param filePath A path to the archive file - * - * @return Returns a UZKArchive object, or nil if the path isn't reachable - */ -+ (nullable instancetype)zipArchiveAtPath:(NSString *)filePath __deprecated_msg("Use -initWithPath:error: instead"); - -/** - * DEPRECATED: Creates and returns an archive at the given URL - * - * @param fileURL The URL of the archive file - * - * @return Returns a UZKArchive object, or nil if the URL isn't reachable - */ -+ (nullable instancetype)zipArchiveAtURL:(NSURL *)fileURL __deprecated_msg("Use -initWithURL:error: instead"); - -/** - * DEPRECATED: Creates and returns an archive at the given path, with a given password - * - * @param filePath A path to the archive file - * @param password The password of the given archive - * - * @return Returns a UZKArchive object, or nil if the path isn't reachable - */ -+ (nullable instancetype)zipArchiveAtPath:(NSString *)filePath password:(nullable NSString *)password __deprecated_msg("Use -initWithPath:password:error: instead"); - -/** - * DEPRECATED: Creates and returns an archive at the given URL, with a given password - * - * @param fileURL The URL of the archive file - * @param password The password of the given archive - * - * @return Returns a UZKArchive object, or nil if the URL isn't reachable - */ -+ (nullable instancetype)zipArchiveAtURL:(NSURL *)fileURL password:(nullable NSString *)password __deprecated_msg("Use -initWithURL:password:error: instead");; - - /** * Creates and returns an archive at the given path * @@ -318,25 +279,6 @@ extern NSString *UZKErrorDomain; overwrite:(BOOL)overwrite error:(NSError **)error; -/** - * **DEPRECATED:** Writes all files in the archive to the given path - * - * @param destinationDirectory The destination path of the unarchived files - * @param overwrite YES to overwrite files in the destination directory, NO otherwise - * @param progress Called every so often to report the progress of the extraction - * - * - *currentFile* The info about the file that's being extracted - * - *percentArchiveDecompressed* The percentage of the archive that has been decompressed - * - * @param error Contains an NSError object when there was an error reading the archive - * - * @return YES on successful extraction, NO if an error was encountered - */ -- (BOOL)extractFilesTo:(NSString *)destinationDirectory - overwrite:(BOOL)overwrite - progress:(nullable void (^)(UZKFileInfo *currentFile, CGFloat percentArchiveDecompressed))progress - error:(NSError **)error __deprecated_msg("Use -extractFilesTo:overwrite:error: instead, and if using the progress block, replace with NSProgress as described in the README"); - /** * Unarchive a single file from the archive into memory. Supports NSProgress for progress reporting, which also * allows cancellation in the middle of extraction @@ -349,22 +291,6 @@ extern NSString *UZKErrorDomain; - (nullable NSData *)extractData:(UZKFileInfo *)fileInfo error:(NSError **)error; -/** - * **DEPRECATED:** Unarchive a single file from the archive into memory - * - * @param fileInfo The info of the file within the archive to be expanded. Only the filename property is used - * @param progress Called every so often to report the progress of the extraction - * - * - *percentDecompressed* The percentage of the archive that has been decompressed - * - * @param error Contains an NSError object when there was an error reading the archive - * - * @return An NSData object containing the bytes of the file, or nil if an error was encountered - */ -- (nullable NSData *)extractData:(UZKFileInfo *)fileInfo - progress:(nullable void (^)(CGFloat percentDecompressed))progress - error:(NSError **)error __deprecated_msg("Use -extractData:error: instead, and if using the progress block, replace with NSProgress as described in the README"); - /** * Unarchive a single file from the archive into memory. Supports NSProgress for progress reporting, which also * allows cancellation in the middle of extraction @@ -377,22 +303,6 @@ extern NSString *UZKErrorDomain; - (nullable NSData *)extractDataFromFile:(NSString *)filePath error:(NSError **)error; -/** - * **DEPRECATED:** Unarchive a single file from the archive into memory - * - * @param filePath The path of the file within the archive to be expanded - * @param progress Called every so often to report the progress of the extraction - * - * - *percentDecompressed* The percentage of the file that has been decompressed - * - * @param error Contains an NSError object when there was an error reading the archive - * - * @return An NSData object containing the bytes of the file, or nil if an error was encountered - */ -- (nullable NSData *)extractDataFromFile:(NSString *)filePath - progress:(nullable void (^)(CGFloat percentDecompressed))progress - error:(NSError **)error __deprecated_msg("Use -extractDataFromFile:error: instead, and if using the progress block, replace with NSProgress as described in the README"); - /** * Loops through each file in the archive into memory, allowing you to perform an action * using its info. Supports NSProgress for progress reporting, which also @@ -495,25 +405,6 @@ extern NSString *UZKErrorDomain; filePath:(NSString *)filePath error:(NSError **)error; -/** - * **DEPRECATED:** Writes the data to the zip file, overwriting it if a file of that name already exists in the - * archive - * - * @param data Data to write into the archive - * @param filePath The full path to the target file in the archive - * @param progress Called every so often to report the progress of the compression - * - * - *percentCompressed* The percentage of the file that has been compressed - * - * @param error Contains an NSError object when there was an error writing to the archive - * - * @return YES if successful, NO on error - */ -- (BOOL)writeData:(NSData *)data - filePath:(NSString *)filePath - progress:(nullable void (^)(CGFloat percentCompressed))progress - error:(NSError **)error __deprecated_msg("Use -writeData:filePath:error: instead, and if using the progress block, replace with NSProgress as described in the README"); - /** * Writes the data to the zip file, overwriting it if a file of that name already exists in the archive * @@ -529,26 +420,6 @@ extern NSString *UZKErrorDomain; fileDate:(nullable NSDate *)fileDate error:(NSError **)error; -/** - * **DEPRECATED:** Writes the data to the zip file, overwriting it if a file of that name already exists in the archive - * - * @param data Data to write into the archive - * @param filePath The full path to the target file in the archive - * @param fileDate The timestamp of the file in the archive. Uses the current time if nil - * @param progress Called every so often to report the progress of the compression - * - * - *percentCompressed* The percentage of the file that has been compressed - * - * @param error Contains an NSError object when there was an error writing to the archive - * - * @return YES if successful, NO on error - */ -- (BOOL)writeData:(NSData *)data - filePath:(NSString *)filePath - fileDate:(nullable NSDate *)fileDate - progress:(nullable void (^)(CGFloat percentCompressed))progress - error:(NSError **)error __deprecated_msg("Use -writeData:filePath:fileDate:error: instead, and if using the progress block, replace with NSProgress as described in the README"); - /** * Writes the data to the zip file, overwriting it if a file of that name already exists in the archive * @@ -568,30 +439,6 @@ compressionMethod:(UZKCompressionMethod)method password:(nullable NSString *)password error:(NSError **)error; -/** - * **DEPRECATED:** Writes the data to the zip file, overwriting it if a file of that name already exists in the archive - * - * @param data Data to write into the archive - * @param filePath The full path to the target file in the archive - * @param fileDate The timestamp of the file in the archive. Uses the current time if nil - * @param method The UZKCompressionMethod to use (Default, None, Fastest, Best) - * @param password Override the password associated with the archive (not recommended) - * @param progress Called every so often to report the progress of the compression - * - * - *percentCompressed* The percentage of the file that has been compressed - * - * @param error Contains an NSError object when there was an error writing to the archive - * - * @return YES if successful, NO on error - */ -- (BOOL)writeData:(NSData *)data - filePath:(NSString *)filePath - fileDate:(nullable NSDate *)fileDate -compressionMethod:(UZKCompressionMethod)method - password:(nullable NSString *)password - progress:(nullable void (^)(CGFloat percentCompressed))progress - error:(NSError **)error __deprecated_msg("Use -writeData:filePath:fileDate:compressionMethod:password:error: instead, and if using the progress block, replace with NSProgress as described in the README"); - /** * Writes the data to the zip file, overwriting only if specified with the overwrite flag. Overwriting * presents a tradeoff: the whole archive needs to be copied (minus the file to be overwritten) before @@ -646,70 +493,6 @@ compressionMethod:(UZKCompressionMethod)method overwrite:(BOOL)overwrite error:(NSError **)error; -/** - * **DEPRECATED:** Writes the data to the zip file, overwriting only if specified with the overwrite flag. Overwriting - * presents a tradeoff: the whole archive needs to be copied (minus the file to be overwritten) before - * the write begins. For a large archive, this can be slow. On the other hand, when not overwriting, - * the size of the archive will grow each time the file is written. - * - * @param data Data to write into the archive - * @param filePath The full path to the target file in the archive - * @param fileDate The timestamp of the file in the archive. Uses the current time if nil - * @param method The UZKCompressionMethod to use (Default, None, Fastest, Best) - * @param password Override the password associated with the archive (not recommended) - * @param overwrite If YES, and the file exists, delete it before writing. If NO, append - * the data into the archive without removing it first (legacy Objective-Zip - * behavior) - * @param progress Called every so often to report the progress of the compression - * - * - *percentCompressed* The percentage of the file that has been compressed - * - * @param error Contains an NSError object when there was an error writing to the archive - * - * @return YES if successful, NO on error - */ -- (BOOL)writeData:(NSData *)data - filePath:(NSString *)filePath - fileDate:(nullable NSDate *)fileDate -compressionMethod:(UZKCompressionMethod)method - password:(nullable NSString *)password - overwrite:(BOOL)overwrite - progress:(nullable void (^)(CGFloat percentCompressed))progress - error:(NSError **)error __deprecated_msg("Use -writeData:filePath:fileDate:compressionMethod:password:overwrite:error: instead, and if using the progress block, replace with NSProgress as described in the README"); - -/** - * **DEPRECATED:** Writes the data to the zip file, overwriting only if specified with the overwrite flag. Overwriting - * presents a tradeoff: the whole archive needs to be copied (minus the file to be overwritten) before - * the write begins. For a large archive, this can be slow. On the other hand, when not overwriting, - * the size of the archive will grow each time the file is written. - * - * @param data Data to write into the archive - * @param filePath The full path to the target file in the archive - * @param fileDate The timestamp of the file in the archive. Uses the current time if nil - * @param permissions The desired POSIX permissions of the file in the archive - * @param method The UZKCompressionMethod to use (Default, None, Fastest, Best) - * @param password Override the password associated with the archive (not recommended) - * @param overwrite If YES, and the file exists, delete it before writing. If NO, append - * the data into the archive without removing it first (legacy Objective-Zip - * behavior) - * @param progress Called every so often to report the progress of the compression - * - * - *percentCompressed* The percentage of the file that has been compressed - * - * @param error Contains an NSError object when there was an error writing to the archive - * - * @return YES if successful, NO on error - */ -- (BOOL)writeData:(NSData *)data - filePath:(NSString *)filePath - fileDate:(nullable NSDate *)fileDate - posixPermissions:(short)permissions -compressionMethod:(UZKCompressionMethod)method - password:(nullable NSString *)password - overwrite:(BOOL)overwrite - progress:(nullable void (^)(CGFloat percentCompressed))progress - error:(NSError **)error __deprecated_msg("Use -writeData:filePath:fileDate:permissions:compressionMethod:password:overwrite:error: instead, and if using the progress block, replace with NSProgress as described in the README"); - /** * Writes data to the zip file in pieces, allowing you to stream the write, so the entire contents * don't need to reside in memory at once. It overwrites an existing file with the same name. diff --git a/Source/UZKArchive.m b/Source/UZKArchive.m index a8ac32a..faf55c1 100644 --- a/Source/UZKArchive.m +++ b/Source/UZKArchive.m @@ -69,31 +69,6 @@ @implementation UZKArchive @synthesize comment = _comment; -#pragma mark - Deprecated Convenience Methods - - -+ (UZKArchive *)zipArchiveAtPath:(NSString *)filePath -{ - return [[UZKArchive alloc] initWithPath:filePath error:nil]; -} - -+ (UZKArchive *)zipArchiveAtURL:(NSURL *)fileURL -{ - return [[UZKArchive alloc] initWithURL:fileURL error:nil]; -} - -+ (UZKArchive *)zipArchiveAtPath:(NSString *)filePath password:(NSString *)password -{ - return [[UZKArchive alloc] initWithPath:filePath password:password error:nil]; -} - -+ (UZKArchive *)zipArchiveAtURL:(NSURL *)fileURL password:(NSString *)password -{ - return [[UZKArchive alloc] initWithURL:fileURL password:password error:nil]; -} - - - #pragma mark - Initializers + (void)initialize { @@ -468,20 +443,6 @@ + (BOOL)urlIsAZip:(NSURL *)fileURL - (BOOL)extractFilesTo:(NSString *)destinationDirectory overwrite:(BOOL)overwrite error:(NSError * __autoreleasing*)error -{ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - return [self extractFilesTo:destinationDirectory - overwrite:overwrite - progress:nil - error:error]; -#pragma clang diagnostic pop -} - -- (BOOL)extractFilesTo:(NSString *)destinationDirectory - overwrite:(BOOL)overwrite - progress:(void (^)(UZKFileInfo *currentFile, CGFloat percentArchiveDecompressed))progressBlock - error:(NSError * __autoreleasing*)error { UZKCreateActivity("Extracting Files to Directory"); @@ -530,10 +491,6 @@ - (BOOL)extractFilesTo:(NSString *)destinationDirectory } @autoreleasepool { - if (progressBlock) { - progressBlock(info, bytesDecompressed / totalSize.doubleValue); - } - if (![self locateFileInZip:info.filename error:&strongError]) { NSString *detail = [NSString localizedStringWithFormat:NSLocalizedStringFromTableInBundle(@"Error locating file '%@' in archive", @"UnzipKit", _resources, @"Detailed error string"), info.filename]; @@ -618,9 +575,6 @@ - (BOOL)extractFilesTo:(NSString *)destinationDirectory UZKLogDebug("Writing data chunk of size %lu (%lld total so far)", (unsigned long)dataChunk.length, bytesDecompressed); bytesDecompressed += dataChunk.length; [deflatedFileHandle writeData:dataChunk]; - if (progressBlock) { - progressBlock(info, (double)bytesDecompressed / totalSize.doubleValue); - } }]; UZKLogDebug("Closing file handle"); @@ -670,29 +624,8 @@ - (nullable NSData *)extractData:(UZKFileInfo *)fileInfo error:error]; } -- (nullable NSData *)extractData:(UZKFileInfo *)fileInfo - progress:(void (^)(CGFloat))progress - error:(NSError * __autoreleasing*)error -{ - return [self extractDataFromFile:fileInfo.filename - progress:progress - error:error]; -} - - (nullable NSData *)extractDataFromFile:(NSString *)filePath error:(NSError * __autoreleasing *)error -{ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - return [self extractDataFromFile:filePath - progress:nil - error:error]; -#pragma clang diagnostic pop -} - -- (nullable NSData *)extractDataFromFile:(NSString *)filePath - progress:(void (^)(CGFloat))progressBlock - error:(NSError * __autoreleasing*)error { UZKCreateActivity("Extracting Data from File"); @@ -705,19 +638,9 @@ - (nullable NSData *)extractDataFromFile:(NSString *)filePath error:&extractError action:^(NSData *dataChunk, CGFloat percentDecompressed) { UZKLogDebug("Appending data chunk of size %lu (%.3f%% complete)", (unsigned long)dataChunk.length, (double)percentDecompressed * 100); - - if (progressBlock) { - progressBlock(percentDecompressed); - } - [result appendData:dataChunk]; }]; - if (progressBlock) { - UZKLogDebug("Declaring extraction progress as completed"); - progressBlock(1.0); - } - if (success) { return [NSData dataWithData:result]; } @@ -1066,21 +989,6 @@ - (BOOL)writeData:(NSData *)data error:error]; } -- (BOOL)writeData:(NSData *)data - filePath:(NSString *)filePath - progress:(void (^)(CGFloat percentCompressed))progress - error:(NSError * __autoreleasing*)error -{ - return [self writeData:data - filePath:filePath - fileDate:nil - compressionMethod:UZKCompressionMethodDefault - password:nil - overwrite:YES - progress:progress - error:error]; -} - - (BOOL)writeData:(NSData *)data filePath:(NSString *)filePath fileDate:(NSDate *)fileDate @@ -1095,44 +1003,11 @@ - (BOOL)writeData:(NSData *)data error:error]; } -- (BOOL)writeData:(NSData *)data - filePath:(NSString *)filePath - fileDate:(NSDate *)fileDate - progress:(void (^)(CGFloat percentCompressed))progress - error:(NSError * __autoreleasing*)error -{ - return [self writeData:data - filePath:filePath - fileDate:fileDate - compressionMethod:UZKCompressionMethodDefault - password:nil - overwrite:YES - progress:progress - error:error]; -} - -- (BOOL)writeData:(NSData *)data - filePath:(NSString *)filePath - fileDate:(NSDate *)fileDate -compressionMethod:(UZKCompressionMethod)method - password:(NSString *)password - error:(NSError * __autoreleasing*)error -{ - return [self writeData:data - filePath:filePath - fileDate:fileDate - compressionMethod:method - password:password - overwrite:YES - error:error]; -} - - (BOOL)writeData:(NSData *)data filePath:(NSString *)filePath fileDate:(NSDate *)fileDate compressionMethod:(UZKCompressionMethod)method password:(NSString *)password - progress:(void (^)(CGFloat percentCompressed))progress error:(NSError * __autoreleasing*)error { return [self writeData:data @@ -1141,7 +1016,6 @@ - (BOOL)writeData:(NSData *)data compressionMethod:method password:password overwrite:YES - progress:progress error:error]; } @@ -1152,28 +1026,6 @@ - (BOOL)writeData:(NSData *)data password:(NSString *)password overwrite:(BOOL)overwrite error:(NSError * __autoreleasing*)error -{ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - return [self writeData:data - filePath:filePath - fileDate:fileDate - compressionMethod:method - password:password - overwrite:overwrite - progress:nil - error:error]; -#pragma clang diagnostic pop -} - -- (BOOL)writeData:(NSData *)data - filePath:(NSString *)filePath - fileDate:(NSDate *)fileDate -compressionMethod:(UZKCompressionMethod)method - password:(NSString *)password - overwrite:(BOOL)overwrite - progress:(void (^)(CGFloat percentCompressed))progressBlock - error:(NSError * __autoreleasing*)error { return [self writeData:data filePath:filePath @@ -1182,33 +1034,9 @@ - (BOOL)writeData:(NSData *)data compressionMethod:method password:password overwrite:overwrite - progress:progressBlock error:error]; } -- (BOOL)writeData:(NSData *)data - filePath:(NSString *)filePath - fileDate:(nullable NSDate *)fileDate - posixPermissions:(short)permissions -compressionMethod:(UZKCompressionMethod)method - password:(nullable NSString *)password - overwrite:(BOOL)overwrite - error:(NSError * __autoreleasing*)error -{ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - return [self writeData:data - filePath:filePath - fileDate:fileDate - posixPermissions:permissions - compressionMethod:method - password:password - overwrite:overwrite - progress:nil - error:error]; -#pragma clang diagnostic pop -} - - (BOOL)writeData:(NSData *)data filePath:(NSString *)filePath fileDate:(NSDate *)fileDate @@ -1216,15 +1044,14 @@ - (BOOL)writeData:(NSData *)data compressionMethod:(UZKCompressionMethod)method password:(NSString *)password overwrite:(BOOL)overwrite - progress:(void (^)(CGFloat percentCompressed))progressBlock error:(NSError * __autoreleasing*)error { UZKCreateActivity("Writing Data"); UZKLogInfo("Writing data to archive. filePath: %{public}@, fileDate: %{time_t}ld, compressionMethod: %ld, password: %{public}@, " - "overwrite: %{public}@, progress block specified: %{public}@, error pointer specified: %{public}@", + "overwrite: %{public}@, error pointer specified: %{public}@", filePath, lrint(fileDate.timeIntervalSince1970), (long)method, password != nil ? @"" : @"(null)", overwrite ? @"YES" : @"NO", - progressBlock ? @"YES" : @"NO", error ? @"YES" : @"NO"); + error ? @"YES" : @"NO"); const NSUInteger bufferSize = 4096; //Arbitrary const void *bytes = data.bytes; @@ -1232,11 +1059,6 @@ - (BOOL)writeData:(NSData *)data NSProgress *progress = [self beginProgressOperation:data.length]; progress.cancellable = NO; - if (progressBlock) { - UZKLogDebug("Calling progress block with zero"); - progressBlock(0); - } - __weak UZKArchive *welf = self; uLong calculatedCRC = crc32(0, data.bytes, (uInt)data.length); UZKLogDebug("Calculated CRC: %010lu", calculatedCRC); @@ -1262,12 +1084,6 @@ - (BOOL)writeData:(NSData *)data } progress.completedUnitCount += size; - - if (progressBlock) { - double percentComplete = i / (double)data.length; - UZKLogDebug("Calling progress block at %.3f%%", percentComplete * 100); - progressBlock(percentComplete); - } } return ZIP_OK;