added iOS source code
[wl-app.git] / iOS / Pods / SSZipArchive / SSZipArchive / SSZipArchive.h
1 //
2 //  SSZipArchive.h
3 //  SSZipArchive
4 //
5 //  Created by Sam Soffes on 7/21/10.
6 //  Copyright (c) Sam Soffes 2010-2015. All rights reserved.
7 //
8
9 #ifndef _SSZIPARCHIVE_H
10 #define _SSZIPARCHIVE_H
11
12 #import <Foundation/Foundation.h>
13 #include "SSZipCommon.h"
14
15 NS_ASSUME_NONNULL_BEGIN
16
17 extern NSString *const SSZipArchiveErrorDomain;
18 typedef NS_ENUM(NSInteger, SSZipArchiveErrorCode) {
19     SSZipArchiveErrorCodeFailedOpenZipFile      = -1,
20     SSZipArchiveErrorCodeFailedOpenFileInZip    = -2,
21     SSZipArchiveErrorCodeFileInfoNotLoadable    = -3,
22     SSZipArchiveErrorCodeFileContentNotReadable = -4,
23     SSZipArchiveErrorCodeFailedToWriteFile      = -5,
24     SSZipArchiveErrorCodeInvalidArguments       = -6,
25 };
26
27 @protocol SSZipArchiveDelegate;
28
29 @interface SSZipArchive : NSObject
30
31 // Password check
32 + (BOOL)isFilePasswordProtectedAtPath:(NSString *)path;
33 + (BOOL)isPasswordValidForArchiveAtPath:(NSString *)path password:(NSString *)pw error:(NSError * _Nullable * _Nullable)error NS_SWIFT_NOTHROW;
34
35 // Unzip
36 + (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination;
37 + (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination delegate:(nullable id<SSZipArchiveDelegate>)delegate;
38
39 + (BOOL)unzipFileAtPath:(NSString *)path
40           toDestination:(NSString *)destination
41               overwrite:(BOOL)overwrite
42                password:(nullable NSString *)password
43                   error:(NSError * *)error;
44
45 + (BOOL)unzipFileAtPath:(NSString *)path
46           toDestination:(NSString *)destination
47               overwrite:(BOOL)overwrite
48                password:(nullable NSString *)password
49                   error:(NSError * *)error
50                delegate:(nullable id<SSZipArchiveDelegate>)delegate NS_REFINED_FOR_SWIFT;
51
52 + (BOOL)unzipFileAtPath:(NSString *)path
53           toDestination:(NSString *)destination
54      preserveAttributes:(BOOL)preserveAttributes
55               overwrite:(BOOL)overwrite
56                password:(nullable NSString *)password
57                   error:(NSError * *)error
58                delegate:(nullable id<SSZipArchiveDelegate>)delegate;
59
60 + (BOOL)unzipFileAtPath:(NSString *)path
61           toDestination:(NSString *)destination
62         progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
63       completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler;
64
65 + (BOOL)unzipFileAtPath:(NSString *)path
66           toDestination:(NSString *)destination
67               overwrite:(BOOL)overwrite
68                password:(nullable NSString *)password
69         progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
70       completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler;
71
72 + (BOOL)unzipFileAtPath:(NSString *)path
73           toDestination:(NSString *)destination
74      preserveAttributes:(BOOL)preserveAttributes
75               overwrite:(BOOL)overwrite
76          nestedZipLevel:(NSInteger)nestedZipLevel
77                password:(nullable NSString *)password
78                   error:(NSError **)error
79                delegate:(nullable id<SSZipArchiveDelegate>)delegate
80         progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
81       completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler;
82
83 // Zip
84 // default compression level is Z_DEFAULT_COMPRESSION (from "zlib.h")
85
86 // without password
87 + (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray<NSString *> *)paths;
88 + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath;
89
90 + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory;
91
92 // with optional password, default encryption is AES
93 // don't use AES if you need compatibility with native macOS unzip and Archive Utility
94 + (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray<NSString *> *)paths withPassword:(nullable NSString *)password;
95 + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath withPassword:(nullable NSString *)password;
96 + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password;
97 + (BOOL)createZipFileAtPath:(NSString *)path
98     withContentsOfDirectory:(NSString *)directoryPath
99         keepParentDirectory:(BOOL)keepParentDirectory
100                withPassword:(nullable NSString *)password
101          andProgressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler;
102 + (BOOL)createZipFileAtPath:(NSString *)path
103     withContentsOfDirectory:(NSString *)directoryPath
104         keepParentDirectory:(BOOL)keepParentDirectory
105            compressionLevel:(int)compressionLevel
106                    password:(nullable NSString *)password
107                         AES:(BOOL)aes
108             progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler;
109
110 - (instancetype)init NS_UNAVAILABLE;
111 - (instancetype)initWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER;
112 - (BOOL)open;
113
114 /// write empty folder
115 - (BOOL)writeFolderAtPath:(NSString *)path withFolderName:(NSString *)folderName withPassword:(nullable NSString *)password;
116 /// write file
117 - (BOOL)writeFile:(NSString *)path withPassword:(nullable NSString *)password;
118 - (BOOL)writeFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName withPassword:(nullable NSString *)password;
119 - (BOOL)writeFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes;
120 /// write data
121 - (BOOL)writeData:(NSData *)data filename:(nullable NSString *)filename withPassword:(nullable NSString *)password;
122 - (BOOL)writeData:(NSData *)data filename:(nullable NSString *)filename compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes;
123
124 - (BOOL)close;
125
126 @end
127
128 @protocol SSZipArchiveDelegate <NSObject>
129
130 @optional
131
132 - (void)zipArchiveWillUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo;
133 - (void)zipArchiveDidUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo unzippedPath:(NSString *)unzippedPath;
134
135 - (BOOL)zipArchiveShouldUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
136 - (void)zipArchiveWillUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
137 - (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
138 - (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath unzippedFilePath:(NSString *)unzippedFilePath;
139
140 - (void)zipArchiveProgressEvent:(unsigned long long)loaded total:(unsigned long long)total;
141
142 @end
143
144 NS_ASSUME_NONNULL_END
145
146 #endif /* _SSZIPARCHIVE_H */