2015-10-23 14:15:31 -04:00
|
|
|
//
|
|
|
|
|
// SSZipArchive.h
|
|
|
|
|
// SSZipArchive
|
|
|
|
|
//
|
|
|
|
|
// Created by Sam Soffes on 7/21/10.
|
|
|
|
|
// Copyright (c) Sam Soffes 2010-2015. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#ifndef _SSZIPARCHIVE_H
|
|
|
|
|
#define _SSZIPARCHIVE_H
|
|
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
2015-11-16 10:46:30 -08:00
|
|
|
#include "Common.h"
|
2015-10-23 14:15:31 -04:00
|
|
|
|
|
|
|
|
@protocol SSZipArchiveDelegate;
|
|
|
|
|
|
|
|
|
|
@interface SSZipArchive : NSObject
|
|
|
|
|
|
|
|
|
|
// Unzip
|
|
|
|
|
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination;
|
|
|
|
|
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination delegate:(id<SSZipArchiveDelegate>)delegate;
|
|
|
|
|
|
2015-11-24 10:31:51 -08:00
|
|
|
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(NSString *)password error:(NSError * *)error;
|
|
|
|
|
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(NSString *)password error:(NSError * *)error delegate:(id<SSZipArchiveDelegate>)delegate;
|
2015-10-23 14:15:31 -04:00
|
|
|
|
|
|
|
|
+ (BOOL)unzipFileAtPath:(NSString *)path
|
2015-11-24 10:31:51 -08:00
|
|
|
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;
|
2015-10-23 14:15:31 -04:00
|
|
|
|
|
|
|
|
+ (BOOL)unzipFileAtPath:(NSString *)path
|
2015-11-24 10:31:51 -08:00
|
|
|
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;
|
2015-10-23 14:15:31 -04:00
|
|
|
|
2015-10-29 06:57:03 +08:00
|
|
|
// Zip
|
2015-11-24 10:31:51 -08:00
|
|
|
|
|
|
|
|
// without password
|
|
|
|
|
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths;
|
2015-10-29 06:57:03 +08:00
|
|
|
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath;
|
2015-11-24 10:31:51 -08:00
|
|
|
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirector;
|
|
|
|
|
|
|
|
|
|
// with password, password could be nil
|
|
|
|
|
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths withPassword:(NSString *)password;
|
|
|
|
|
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath withPassword:(NSString *)password;
|
|
|
|
|
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(NSString *)password;
|
2015-10-23 14:15:31 -04:00
|
|
|
|
|
|
|
|
- (instancetype)initWithPath:(NSString *)path;
|
2015-11-17 15:17:13 +01:00
|
|
|
@property (NS_NONATOMIC_IOSONLY, readonly, getter = isOpen) BOOL open;
|
2015-11-24 10:31:51 -08:00
|
|
|
- (BOOL)writeFile:(NSString *)path withPassword:(NSString *)password;
|
2015-12-07 09:37:56 +01:00
|
|
|
- (BOOL)writeFolderAtPath:(NSString *)path withFolderName:(NSString *)folderName;
|
2015-11-24 10:31:51 -08:00
|
|
|
- (BOOL)writeFileAtPath:(NSString *)path withFileName:(NSString *)fileName withPassword:(NSString *)password;
|
|
|
|
|
- (BOOL)writeData:(NSData *)data filename:(NSString *)filename withPassword:(NSString *)password;
|
2015-11-17 15:17:13 +01:00
|
|
|
@property (NS_NONATOMIC_IOSONLY, readonly, getter = isClosed) BOOL close;
|
2015-10-23 14:15:31 -04:00
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@protocol SSZipArchiveDelegate <NSObject>
|
|
|
|
|
|
|
|
|
|
@optional
|
|
|
|
|
|
|
|
|
|
- (void)zipArchiveWillUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo;
|
|
|
|
|
- (void)zipArchiveDidUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo unzippedPath:(NSString *)unzippedPath;
|
|
|
|
|
|
|
|
|
|
- (BOOL)zipArchiveShouldUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
|
|
|
|
|
- (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;
|
|
|
|
|
- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath unzippedFilePath:(NSString *)unzippedFilePath;
|
|
|
|
|
|
|
|
|
|
- (void)zipArchiveProgressEvent:(unsigned long long)loaded total:(unsigned long long)total;
|
|
|
|
|
- (void)zipArchiveDidUnzipArchiveFile:(NSString *)zipFile entryPath:(NSString *)entryPath destPath:(NSString *)destPath;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
#endif /* _SSZIPARCHIVE_H */
|