SSZipArchive.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #ifndef _SSZIPARCHIVE_H
  9. #define _SSZIPARCHIVE_H
  10. #import <Foundation/Foundation.h>
  11. #include "unzip.h"
  12. @protocol SSZipArchiveDelegate;
  13. @interface SSZipArchive : NSObject
  14. // Unzip
  15. + (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination;
  16. + (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination delegate:(id<SSZipArchiveDelegate>)delegate;
  17. + (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(NSString *)password error:(NSError **)error;
  18. + (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(NSString *)password error:(NSError **)error delegate:(id<SSZipArchiveDelegate>)delegate;
  19. + (BOOL)unzipFileAtPath:(NSString *)path
  20. toDestination:(NSString *)destination
  21. progressHandler:(void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
  22. completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError *error))completionHandler;
  23. + (BOOL)unzipFileAtPath:(NSString *)path
  24. toDestination:(NSString *)destination
  25. overwrite:(BOOL)overwrite
  26. password:(NSString *)password
  27. progressHandler:(void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
  28. completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError *error))completionHandler;
  29. // Zip
  30. + (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)filenames;
  31. + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath;
  32. + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory;
  33. - (id)initWithPath:(NSString *)path;
  34. - (BOOL)open;
  35. - (BOOL)writeFile:(NSString *)path;
  36. - (BOOL)writeFileAtPath:(NSString *)path withFileName:(NSString *)fileName;
  37. - (BOOL)writeData:(NSData *)data filename:(NSString *)filename;
  38. - (BOOL)close;
  39. @end
  40. @protocol SSZipArchiveDelegate <NSObject>
  41. @optional
  42. - (void)zipArchiveWillUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo;
  43. - (void)zipArchiveDidUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo unzippedPath:(NSString *)unzippedPath;
  44. - (BOOL)zipArchiveShouldUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
  45. - (void)zipArchiveWillUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
  46. - (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
  47. - (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath unzippedFilePath:(NSString *)unzippedFilePath;
  48. - (void)zipArchiveProgressEvent:(unsigned long long)loaded total:(unsigned long long)total;
  49. - (void)zipArchiveDidUnzipArchiveFile:(NSString *)zipFile entryPath:(NSString *)entryPath destPath:(NSString *)destPath;
  50. @end
  51. #endif /* _SSZIPARCHIVE_H */