forked from mattconnolly/ZipArchive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZipArchive.h
90 lines (66 loc) · 2.55 KB
/
ZipArchive.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
// @header ZipArchive.h
//
// An objective C wrapper for minizip and libz for creating and exanding ZIP files.
//
// @author Created by aish on 08-9-11.
// @copyright Copyright 2008 Inc. All rights reserved.
//
*/
#import <UIKit/UIKit.h>
#include "minizip/zip.h"
#include "minizip/unzip.h"
/**
@protocol
@discussion methods for a delegate to receive error notifications and control overwriting of files
*/
@protocol ZipArchiveDelegate <NSObject>
@optional
/**
@brief Delegate method to be notified of errors
ZipArchive calls this selector on the delegate when errors are encountered.
@param msg a string describing the error.
@result void
*/
-(void) ErrorMessage:(NSString*) msg;
/**
@brief Delegate method to determine if a file should be replaced
When an zip file is being expanded and a file is about to be replaced, this selector
is called on the delegate to notify that file is about to be replaced. The delegate method
should return YES to overwrite the file, or NO to skip it.
@param file - path to the file to be overwritten.
@result a BOOL - YES to replace, NO to skip
*/
-(BOOL) OverWriteOperation:(NSString*) file;
@end
/**
@class
@brief An object that can create zip files and expand existing ones.
This class provides methods to create a zip file (optionally with a password) and
add files to that zip archive.
It also provides methods to expand an existing archive file (optionally with a password),
and extract the files.
*/
@interface ZipArchive : NSObject {
@private
zipFile _zipFile;
unzFile _unzFile;
NSString* _password;
id _delegate;
NSArray* _unzippedFiles;
}
/** a delegate object conforming to ZipArchiveDelegate protocol */
@property (nonatomic, retain) id<ZipArchiveDelegate> delegate;
/** an array of files that were successfully expanded. Available after calling UnzipFileTo:overWrite: */
@property (nonatomic, readonly) NSArray* unzippedFiles;
-(BOOL) CreateZipFile2:(NSString*) zipFile;
-(BOOL) CreateZipFile2:(NSString*) zipFile Password:(NSString*) password;
-(BOOL) addFileToZip:(NSString*) file newname:(NSString*) newname;
-(BOOL) CloseZipFile2;
-(BOOL) UnzipOpenFile:(NSString*) zipFile;
-(BOOL) UnzipOpenFile:(NSString*) zipFile Password:(NSString*) password;
-(BOOL) UnzipFileTo:(NSString*) path overWrite:(BOOL) overwrite;
-(BOOL) UnzipCloseFile;
-(NSArray*) getZipFileContents; // list the contents of the zip archive. must be called after UnzipOpenFile
@end