Nessuna descrizione

SSZipArchive.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 "Common.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. // without password
  31. + (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths;
  32. + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath;
  33. + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirector;
  34. // with password, password could be nil
  35. + (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths withPassword:(NSString *)password;
  36. + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath withPassword:(NSString *)password;
  37. + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(NSString *)password;
  38. - (instancetype)initWithPath:(NSString *)path;
  39. @property (NS_NONATOMIC_IOSONLY, readonly, getter = isOpen) BOOL open;
  40. - (BOOL)writeFile:(NSString *)path withPassword:(NSString *)password;
  41. //- (BOOL)writeFolderAtPath:(NSString *)path withFolderName:(NSString *)folderName;
  42. - (BOOL)writeFileAtPath:(NSString *)path withFileName:(NSString *)fileName withPassword:(NSString *)password;
  43. - (BOOL)writeData:(NSData *)data filename:(NSString *)filename withPassword:(NSString *)password;
  44. @property (NS_NONATOMIC_IOSONLY, readonly, getter = isClosed) BOOL close;
  45. @end
  46. @protocol SSZipArchiveDelegate <NSObject>
  47. @optional
  48. - (void)zipArchiveWillUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo;
  49. - (void)zipArchiveDidUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo unzippedPath:(NSString *)unzippedPath;
  50. - (BOOL)zipArchiveShouldUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
  51. - (void)zipArchiveWillUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
  52. - (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
  53. - (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath unzippedFilePath:(NSString *)unzippedFilePath;
  54. - (void)zipArchiveProgressEvent:(unsigned long long)loaded total:(unsigned long long)total;
  55. - (void)zipArchiveDidUnzipArchiveFile:(NSString *)zipFile entryPath:(NSString *)entryPath destPath:(NSString *)destPath;
  56. @end
  57. #endif /* _SSZIPARCHIVE_H */