2010-07-21 18:05:38 -05:00
|
|
|
//
|
2010-08-19 15:27:48 -05:00
|
|
|
// SSZipArchive.h
|
|
|
|
|
// SSZipArchive
|
2010-07-21 18:05:38 -05:00
|
|
|
//
|
|
|
|
|
// Created by Sam Soffes on 7/21/10.
|
2015-04-06 17:17:26 -04:00
|
|
|
// Copyright (c) Sam Soffes 2010-2015. All rights reserved.
|
2010-07-21 18:05:38 -05:00
|
|
|
//
|
|
|
|
|
|
2013-03-01 14:40:28 -07:00
|
|
|
#ifndef _SSZIPARCHIVE_H
|
|
|
|
|
#define _SSZIPARCHIVE_H
|
|
|
|
|
|
2011-10-03 23:28:54 -07:00
|
|
|
#import <Foundation/Foundation.h>
|
2013-09-10 00:03:11 -07:00
|
|
|
#include "unzip.h"
|
2012-05-07 22:27:45 -07:00
|
|
|
|
|
|
|
|
@protocol SSZipArchiveDelegate;
|
2011-10-03 23:28:54 -07:00
|
|
|
|
2011-12-26 23:32:55 -05:00
|
|
|
@interface SSZipArchive : NSObject
|
2010-07-21 18:05:38 -05:00
|
|
|
|
2011-12-20 09:24:56 +00:00
|
|
|
// Unzip
|
2010-07-21 18:05:38 -05:00
|
|
|
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination;
|
2012-01-14 20:46:32 +01:00
|
|
|
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination delegate:(id<SSZipArchiveDelegate>)delegate;
|
2014-07-29 18:54:28 +01:00
|
|
|
|
|
|
|
|
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(NSString *)password error:(NSError **)error;
|
2012-01-14 20:46:32 +01:00
|
|
|
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(NSString *)password error:(NSError **)error delegate:(id<SSZipArchiveDelegate>)delegate;
|
|
|
|
|
|
2014-07-29 18:54:28 +01:00
|
|
|
+ (BOOL)unzipFileAtPath:(NSString *)path
|
|
|
|
|
toDestination:(NSString *)destination
|
|
|
|
|
progressHandler:(void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
|
|
|
|
|
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError *error))completionHandler;
|
|
|
|
|
|
|
|
|
|
+ (BOOL)unzipFileAtPath:(NSString *)path
|
|
|
|
|
toDestination:(NSString *)destination
|
|
|
|
|
overwrite:(BOOL)overwrite
|
|
|
|
|
password:(NSString *)password
|
|
|
|
|
progressHandler:(void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
|
|
|
|
|
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError *error))completionHandler;
|
|
|
|
|
|
2011-12-20 09:24:56 +00:00
|
|
|
// Zip
|
|
|
|
|
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)filenames;
|
2013-03-09 05:36:20 -08:00
|
|
|
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath;
|
2014-12-21 18:02:19 -06:00
|
|
|
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory;
|
2011-12-20 09:24:56 +00:00
|
|
|
|
2015-06-06 20:43:47 +03:00
|
|
|
- (instancetype)initWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER;
|
|
|
|
|
@property (NS_NONATOMIC_IOSONLY, readonly) BOOL open;
|
2011-12-20 09:24:56 +00:00
|
|
|
- (BOOL)writeFile:(NSString *)path;
|
2013-04-15 17:29:01 +05:00
|
|
|
- (BOOL)writeFileAtPath:(NSString *)path withFileName:(NSString *)fileName;
|
2011-12-20 09:24:56 +00:00
|
|
|
- (BOOL)writeData:(NSData *)data filename:(NSString *)filename;
|
2015-06-06 20:43:47 +03:00
|
|
|
@property (NS_NONATOMIC_IOSONLY, readonly) BOOL close;
|
2011-12-20 09:24:56 +00:00
|
|
|
|
2010-07-21 18:05:38 -05:00
|
|
|
@end
|
2012-05-07 22:27:45 -07:00
|
|
|
|
|
|
|
|
@protocol SSZipArchiveDelegate <NSObject>
|
|
|
|
|
|
|
|
|
|
@optional
|
|
|
|
|
|
2012-05-07 23:05:06 -07:00
|
|
|
- (void)zipArchiveWillUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo;
|
|
|
|
|
- (void)zipArchiveDidUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo unzippedPath:(NSString *)unzippedPath;
|
|
|
|
|
|
2014-07-16 11:28:25 -07:00
|
|
|
- (BOOL)zipArchiveShouldUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
|
2012-05-07 22:27:45 -07:00
|
|
|
- (void)zipArchiveWillUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
|
|
|
|
|
- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
|
2015-04-09 20:07:03 +02:00
|
|
|
- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath unzippedFilePath:(NSString *)unzippedFilePath;
|
2012-05-07 22:27:45 -07:00
|
|
|
|
2014-09-12 19:11:46 +02:00
|
|
|
- (void)zipArchiveProgressEvent:(unsigned long long)loaded total:(unsigned long long)total;
|
2012-08-01 15:03:29 -07:00
|
|
|
- (void)zipArchiveDidUnzipArchiveFile:(NSString *)zipFile entryPath:(NSString *)entryPath destPath:(NSString *)destPath;
|
2015-04-06 17:18:27 -04:00
|
|
|
|
2012-05-07 22:27:45 -07:00
|
|
|
@end
|
2013-03-01 14:40:28 -07:00
|
|
|
|
|
|
|
|
#endif /* _SSZIPARCHIVE_H */
|