Skip to content

Commit

Permalink
Merge pull request MobileChromeApps#59 from werk85/master
Browse files Browse the repository at this point in the history
SSZipArchive updated to version 1.1
  • Loading branch information
agrieve committed Feb 23, 2016
2 parents 3af1ba0 + aabbb49 commit 266d5de
Show file tree
Hide file tree
Showing 32 changed files with 8,687 additions and 4,225 deletions.
22 changes: 22 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@
<platform name="ios">
<source-file src="src/ios/ZipPlugin.m" />
<header-file src="src/ios/ZipPlugin.h" />
<header-file src="src/ios/Common.h" />
<header-file src="src/ios/aes/aes.h" target-dir="Plugins/aes" />
<header-file src="src/ios/aes/aes_via_ace.h" target-dir="Plugins/aes" />
<source-file src="src/ios/aes/aescrypt.c" target-dir="Plugins/aes" />
<source-file src="src/ios/aes/aeskey.c" target-dir="Plugins/aes" />
<header-file src="src/ios/aes/aesopt.h" target-dir="Plugins/aes" />
<source-file src="src/ios/aes/aestab.c" target-dir="Plugins/aes" />
<header-file src="src/ios/aes/aestab.h" target-dir="Plugins/aes" />
<header-file src="src/ios/aes/brg_endian.h" target-dir="Plugins/aes" />
<header-file src="src/ios/aes/brg_types.h" target-dir="Plugins/aes" />
<source-file src="src/ios/aes/entropy.c" target-dir="Plugins/aes" />
<header-file src="src/ios/aes/entropy.h" target-dir="Plugins/aes" />
<source-file src="src/ios/aes/fileenc.c" target-dir="Plugins/aes" />
<header-file src="src/ios/aes/fileenc.h" target-dir="Plugins/aes" />
<source-file src="src/ios/aes/hmac.c" target-dir="Plugins/aes" />
<header-file src="src/ios/aes/hmac.h" target-dir="Plugins/aes" />
<source-file src="src/ios/aes/prng.c" target-dir="Plugins/aes" />
<header-file src="src/ios/aes/prng.h" target-dir="Plugins/aes" />
<source-file src="src/ios/aes/pwd2key.c" target-dir="Plugins/aes" />
<header-file src="src/ios/aes/pwd2key.h" target-dir="Plugins/aes" />
<source-file src="src/ios/aes/sha1.c" target-dir="Plugins/aes" />
<header-file src="src/ios/aes/sha1.h" target-dir="Plugins/aes" />
<source-file src="src/ios/SSZipArchive.m" target-dir="Plugins/minizip" />
<header-file src="src/ios/SSZipArchive.h" target-dir="Plugins/minizip" />
<source-file src="src/ios/minizip/zip.c" target-dir="Plugins/minizip" />
Expand Down
81 changes: 81 additions & 0 deletions src/ios/Common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#ifndef SSZipCommon
#define SSZipCommon

/* tm_unz contain date/time info */
typedef struct tm_unz_s
{
unsigned int tm_sec; /* seconds after the minute - [0,59] */
unsigned int tm_min; /* minutes after the hour - [0,59] */
unsigned int tm_hour; /* hours since midnight - [0,23] */
unsigned int tm_mday; /* day of the month - [1,31] */
unsigned int tm_mon; /* months since January - [0,11] */
unsigned int tm_year; /* years - [1980..2044] */
} tm_unz;

typedef struct unz_file_info_s
{
unsigned long version; /* version made by 2 bytes */
unsigned long version_needed; /* version needed to extract 2 bytes */
unsigned long flag; /* general purpose bit flag 2 bytes */
unsigned long compression_method; /* compression method 2 bytes */
unsigned long dosDate; /* last mod file date in Dos fmt 4 bytes */
unsigned long crc; /* crc-32 4 bytes */
unsigned long compressed_size; /* compressed size 4 bytes */
unsigned long uncompressed_size; /* uncompressed size 4 bytes */
unsigned long size_filename; /* filename length 2 bytes */
unsigned long size_file_extra; /* extra field length 2 bytes */
unsigned long size_file_comment; /* file comment length 2 bytes */

unsigned long disk_num_start; /* disk number start 2 bytes */
unsigned long internal_fa; /* internal file attributes 2 bytes */
unsigned long external_fa; /* external file attributes 4 bytes */

tm_unz tmu_date;
} unz_file_info;

/* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_info64_s
{
unsigned long version; /* version made by 2 bytes */
unsigned long version_needed; /* version needed to extract 2 bytes */
unsigned long flag; /* general purpose bit flag 2 bytes */
unsigned long compression_method; /* compression method 2 bytes */
unsigned long dosDate; /* last mod file date in Dos fmt 4 bytes */
unsigned long crc; /* crc-32 4 bytes */
unsigned long long compressed_size; /* compressed size 8 bytes */
unsigned long long uncompressed_size; /* uncompressed size 8 bytes */
unsigned long size_filename; /* filename length 2 bytes */
unsigned long size_file_extra; /* extra field length 2 bytes */
unsigned long size_file_comment; /* file comment length 2 bytes */

unsigned long disk_num_start; /* disk number start 2 bytes */
unsigned long internal_fa; /* internal file attributes 2 bytes */
unsigned long external_fa; /* external file attributes 4 bytes */

tm_unz tmu_date;
unsigned long long disk_offset;
unsigned long size_file_extra_internal;
} unz_file_info64;

typedef struct unz_global_info_s
{
unsigned long number_entry; /* total number of entries in
the central dir on this disk */

unsigned long number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/


unsigned long size_comment; /* size of the global comment of the zipfile */
} unz_global_info;

typedef struct unz_global_info64
{
unsigned long long number_entry; /* total number of entries in
the central dir on this disk */

unsigned long number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP*/

unsigned long size_comment; /* size of the global comment of the zipfile */
} unz_global_info64;

#endif
56 changes: 44 additions & 12 deletions src/ios/SSZipArchive.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,59 @@
// SSZipArchive
//
// Created by Sam Soffes on 7/21/10.
// Copyright (c) Sam Soffes 2010-2014. All rights reserved.
// Copyright (c) Sam Soffes 2010-2015. All rights reserved.
//

#ifndef _SSZIPARCHIVE_H
#define _SSZIPARCHIVE_H

#import <Foundation/Foundation.h>
#include "unzip.h"
#include "Common.h"

@protocol SSZipArchiveDelegate;

@interface SSZipArchive : NSObject

// Unzip
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination;
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(NSString *)password error:(NSError **)error;

+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination delegate:(id<SSZipArchiveDelegate>)delegate;
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(NSString *)password error:(NSError **)error delegate:(id<SSZipArchiveDelegate>)delegate;

+ (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;

+ (BOOL)unzipFileAtPath:(NSString *)path
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;

+ (BOOL)unzipFileAtPath:(NSString *)path
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;

// Zip
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)filenames;

- (id)initWithPath:(NSString *)path;
- (BOOL)open;
- (BOOL)writeFile:(NSString *)path;
- (BOOL)writeData:(NSData *)data filename:(NSString *)filename;
- (BOOL)close;
// without password
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths;
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath;
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirector;

@end
// 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;

- (instancetype)initWithPath:(NSString *)path;
@property (NS_NONATOMIC_IOSONLY, readonly, getter = isOpen) BOOL open;
- (BOOL)writeFile:(NSString *)path withPassword:(NSString *)password;
- (BOOL)writeFolderAtPath:(NSString *)path withFolderName:(NSString *)folderName withPassword:(NSString *)password;
- (BOOL)writeFileAtPath:(NSString *)path withFileName:(NSString *)fileName withPassword:(NSString *)password;
- (BOOL)writeData:(NSData *)data filename:(NSString *)filename withPassword:(NSString *)password;
@property (NS_NONATOMIC_IOSONLY, readonly, getter = isClosed) BOOL close;

@end

@protocol SSZipArchiveDelegate <NSObject>

Expand All @@ -39,7 +64,14 @@
- (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 */
Loading

0 comments on commit 266d5de

Please sign in to comment.