Skip to content

Commit 3c18cc3

Browse files
committed
initial commit
Signed-off-by: 82Flex <[email protected]>
0 parents  commit 3c18cc3

24 files changed

+1029
-0
lines changed

.clang-format

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# clang-format
2+
BasedOnStyle: LLVM
3+
IndentWidth: 4
4+
AccessModifierOffset: -4
5+
ContinuationIndentWidth: 4
6+
ColumnLimit: 120

.gitignore

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
__handlers__
2+
.cache
3+
.theos
4+
packages
5+
compile_commands.json
6+
7+
# Created by https://www.toptal.com/developers/gitignore/api/macos,xcode,swift
8+
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,xcode,swift
9+
10+
### macOS ###
11+
# General
12+
.DS_Store
13+
.AppleDouble
14+
.LSOverride
15+
16+
# Icon must end with two \r
17+
Icon
18+
19+
20+
# Thumbnails
21+
._*
22+
23+
# Files that might appear in the root of a volume
24+
.DocumentRevisions-V100
25+
.fseventsd
26+
.Spotlight-V100
27+
.TemporaryItems
28+
.Trashes
29+
.VolumeIcon.icns
30+
.com.apple.timemachine.donotpresent
31+
32+
# Directories potentially created on remote AFP share
33+
.AppleDB
34+
.AppleDesktop
35+
Network Trash Folder
36+
Temporary Items
37+
.apdisk
38+
39+
### macOS Patch ###
40+
# iCloud generated files
41+
*.icloud
42+
43+
### Swift ###
44+
# Xcode
45+
#
46+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
47+
48+
## User settings
49+
xcuserdata/
50+
51+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
52+
*.xcscmblueprint
53+
*.xccheckout
54+
55+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
56+
build/
57+
DerivedData/
58+
*.moved-aside
59+
*.pbxuser
60+
!default.pbxuser
61+
*.mode1v3
62+
!default.mode1v3
63+
*.mode2v3
64+
!default.mode2v3
65+
*.perspectivev3
66+
!default.perspectivev3
67+
68+
## Obj-C/Swift specific
69+
*.hmap
70+
71+
## App packaging
72+
*.ipa
73+
*.dSYM.zip
74+
*.dSYM
75+
76+
## Playgrounds
77+
timeline.xctimeline
78+
playground.xcworkspace
79+
80+
# Swift Package Manager
81+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
82+
# Packages/
83+
# Package.pins
84+
# Package.resolved
85+
# *.xcodeproj
86+
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
87+
# hence it is not needed unless you have added a package configuration file to your project
88+
# .swiftpm
89+
90+
.build/
91+
92+
# CocoaPods
93+
# We recommend against adding the Pods directory to your .gitignore. However
94+
# you should judge for yourself, the pros and cons are mentioned at:
95+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
96+
# Pods/
97+
# Add this line if you want to avoid checking in source code from the Xcode workspace
98+
# *.xcworkspace
99+
100+
# Carthage
101+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
102+
# Carthage/Checkouts
103+
104+
Carthage/Build/
105+
106+
# Accio dependency management
107+
Dependencies/
108+
.accio/
109+
110+
# fastlane
111+
# It is recommended to not store the screenshots in the git repo.
112+
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
113+
# For more information about the recommended setup visit:
114+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
115+
116+
fastlane/report.xml
117+
fastlane/Preview.html
118+
fastlane/screenshots/**/*.png
119+
fastlane/test_output
120+
121+
# Code Injection
122+
# After new code Injection tools there's a generated folder /iOSInjectionProject
123+
# https://github.com/johnno1962/injectionforxcode
124+
125+
iOSInjectionProject/
126+
127+
### Xcode ###
128+
129+
## Xcode 8 and earlier
130+
131+
### Xcode Patch ###
132+
*.xcodeproj/*
133+
!*.xcodeproj/project.pbxproj
134+
!*.xcodeproj/xcshareddata/
135+
!*.xcodeproj/project.xcworkspace/
136+
!*.xcworkspace/contents.xcworkspacedata
137+
/*.gcno
138+
**/xcshareddata/WorkspaceSettings.xcsettings
139+
140+
# End of https://www.toptal.com/developers/gitignore/api/macos,xcode,swift
141+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifdef __OBJC__
2+
#import <UIKit/UIKit.h>
3+
#else
4+
#ifndef FOUNDATION_EXPORT
5+
#if defined(__cplusplus)
6+
#define FOUNDATION_EXPORT extern "C"
7+
#else
8+
#define FOUNDATION_EXPORT extern
9+
#endif
10+
#endif
11+
#endif
12+
13+
#import "SSZipArchive.h"
14+
#import "SSZipCommon.h"
15+
16+
FOUNDATION_EXPORT double SSZipArchiveVersionNumber;
17+
FOUNDATION_EXPORT const unsigned char SSZipArchiveVersionString[];
18+
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
//
2+
// SSZipArchive.h
3+
// SSZipArchive
4+
//
5+
// Created by Sam Soffes on 7/21/10.
6+
//
7+
8+
#ifndef _SSZIPARCHIVE_H
9+
#define _SSZIPARCHIVE_H
10+
11+
#import <Foundation/Foundation.h>
12+
13+
#import "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+
SSZipArchiveErrorCodeSymlinkEscapesTargetDirectory = -7,
26+
};
27+
28+
@protocol SSZipArchiveDelegate;
29+
30+
@interface SSZipArchive : NSObject
31+
32+
// Password check
33+
+ (BOOL)isFilePasswordProtectedAtPath:(NSString *)path;
34+
+ (BOOL)isPasswordValidForArchiveAtPath:(NSString *)path password:(NSString *)pw error:(NSError * _Nullable * _Nullable)error NS_SWIFT_NOTHROW;
35+
36+
// Total payload size
37+
+ (NSNumber *)payloadSizeForArchiveAtPath:(NSString *)path error:(NSError **)error;
38+
39+
// Unzip
40+
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination;
41+
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination delegate:(nullable id<SSZipArchiveDelegate>)delegate;
42+
43+
+ (BOOL)unzipFileAtPath:(NSString *)path
44+
toDestination:(NSString *)destination
45+
overwrite:(BOOL)overwrite
46+
password:(nullable NSString *)password
47+
error:(NSError * *)error;
48+
49+
+ (BOOL)unzipFileAtPath:(NSString *)path
50+
toDestination:(NSString *)destination
51+
overwrite:(BOOL)overwrite
52+
password:(nullable NSString *)password
53+
error:(NSError * *)error
54+
delegate:(nullable id<SSZipArchiveDelegate>)delegate NS_REFINED_FOR_SWIFT;
55+
56+
+ (BOOL)unzipFileAtPath:(NSString *)path
57+
toDestination:(NSString *)destination
58+
preserveAttributes:(BOOL)preserveAttributes
59+
overwrite:(BOOL)overwrite
60+
password:(nullable NSString *)password
61+
error:(NSError * *)error
62+
delegate:(nullable id<SSZipArchiveDelegate>)delegate;
63+
64+
+ (BOOL)unzipFileAtPath:(NSString *)path
65+
toDestination:(NSString *)destination
66+
progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
67+
completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler;
68+
69+
+ (BOOL)unzipFileAtPath:(NSString *)path
70+
toDestination:(NSString *)destination
71+
overwrite:(BOOL)overwrite
72+
password:(nullable NSString *)password
73+
progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
74+
completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler;
75+
76+
+ (BOOL)unzipFileAtPath:(NSString *)path
77+
toDestination:(NSString *)destination
78+
preserveAttributes:(BOOL)preserveAttributes
79+
overwrite:(BOOL)overwrite
80+
nestedZipLevel:(NSInteger)nestedZipLevel
81+
password:(nullable NSString *)password
82+
error:(NSError **)error
83+
delegate:(nullable id<SSZipArchiveDelegate>)delegate
84+
progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
85+
completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler;
86+
87+
+ (BOOL)unzipFileAtPath:(NSString *)path
88+
toDestination:(NSString *)destination
89+
preserveAttributes:(BOOL)preserveAttributes
90+
overwrite:(BOOL)overwrite
91+
symlinksValidWithin:(nullable NSString *)symlinksValidWithin
92+
nestedZipLevel:(NSInteger)nestedZipLevel
93+
password:(nullable NSString *)password
94+
error:(NSError **)error
95+
delegate:(nullable id<SSZipArchiveDelegate>)delegate
96+
progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
97+
completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler;
98+
99+
// Zip
100+
// default compression level is Z_DEFAULT_COMPRESSION (from "zlib.h")
101+
// keepParentDirectory: if YES, then unzipping will give `directoryName/fileName`. If NO, then unzipping will just give `fileName`. Default is NO.
102+
103+
// without password
104+
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray<NSString *> *)paths;
105+
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath;
106+
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory;
107+
108+
// with optional password
109+
// - default is AES encryption
110+
// - don't use AES if you need compatibility with native macOS unzip and Archive Utility
111+
// - disabling AES will fallback to PKWARE traditional encryption
112+
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray<NSString *> *)paths withPassword:(nullable NSString *)password;
113+
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray<NSString *> *)paths withPassword:(nullable NSString *)password progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler;
114+
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath withPassword:(nullable NSString *)password;
115+
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password;
116+
+ (BOOL)createZipFileAtPath:(NSString *)path
117+
withContentsOfDirectory:(NSString *)directoryPath
118+
keepParentDirectory:(BOOL)keepParentDirectory
119+
withPassword:(nullable NSString *)password
120+
andProgressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler;
121+
+ (BOOL)createZipFileAtPath:(NSString *)path
122+
withContentsOfDirectory:(NSString *)directoryPath
123+
keepParentDirectory:(BOOL)keepParentDirectory
124+
compressionLevel:(int)compressionLevel
125+
password:(nullable NSString *)password
126+
AES:(BOOL)aes
127+
progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler;
128+
//suport symlink compress --file
129+
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray<NSString *> *)paths withPassword:(nullable NSString *)password keepSymlinks:(BOOL)keeplinks;
130+
//suport symlink compress --directory
131+
+ (BOOL)createZipFileAtPath:(NSString *)path
132+
withContentsOfDirectory:(NSString *)directoryPath
133+
keepParentDirectory:(BOOL)keepParentDirectory
134+
compressionLevel:(int)compressionLevel
135+
password:(nullable NSString *)password
136+
AES:(BOOL)aes
137+
progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler
138+
keepSymlinks:(BOOL)keeplinks;
139+
140+
- (instancetype)init NS_UNAVAILABLE;
141+
- (instancetype)initWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER;
142+
- (BOOL)open;
143+
- (BOOL)openForAppending;
144+
145+
/// write empty folder
146+
- (BOOL)writeFolderAtPath:(NSString *)path withFolderName:(NSString *)folderName withPassword:(nullable NSString *)password;
147+
/// write file
148+
- (BOOL)writeFile:(NSString *)path withPassword:(nullable NSString *)password;
149+
- (BOOL)writeFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName withPassword:(nullable NSString *)password;
150+
- (BOOL)writeFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes;
151+
/// write symlink files
152+
- (BOOL)writeSymlinkFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes;
153+
/// write data
154+
- (BOOL)writeData:(NSData *)data filename:(nullable NSString *)filename withPassword:(nullable NSString *)password;
155+
- (BOOL)writeData:(NSData *)data filename:(nullable NSString *)filename compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes;
156+
157+
- (BOOL)close;
158+
159+
@end
160+
161+
@protocol SSZipArchiveDelegate <NSObject>
162+
163+
@optional
164+
165+
- (void)zipArchiveWillUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo;
166+
- (void)zipArchiveDidUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo unzippedPath:(NSString *)unzippedPath;
167+
168+
- (BOOL)zipArchiveShouldUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
169+
- (void)zipArchiveWillUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
170+
- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
171+
- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath unzippedFilePath:(NSString *)unzippedFilePath;
172+
173+
- (void)zipArchiveProgressEvent:(unsigned long long)loaded total:(unsigned long long)total;
174+
175+
@end
176+
177+
NS_ASSUME_NONNULL_END
178+
179+
#endif /* _SSZIPARCHIVE_H */
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef SSZipCommon
2+
#define SSZipCommon
3+
4+
// typedefs moved from unzip.h to here for public access
5+
6+
/* unz_global_info structure contain global data about the ZIPfile
7+
These data comes from the end of central dir */
8+
9+
typedef struct unz_global_info_s {
10+
unsigned long number_entry; /* total number of entries in the central dir on this disk */
11+
unsigned long size_comment; /* size of the global comment of the zipfile */
12+
/* minizip-ng fields */
13+
uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP */
14+
} unz_global_info;
15+
16+
/* unz_file_info contain information about a file in the zipfile */
17+
/* https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT */
18+
19+
typedef struct unz_file_info_s {
20+
unsigned long version; /* version made by 2 bytes */
21+
unsigned long version_needed; /* version needed to extract 2 bytes */
22+
unsigned long flag; /* general purpose bit flag 2 bytes */
23+
unsigned long compression_method; /* compression method 2 bytes */
24+
unsigned long dos_date; /* last mod file date in Dos fmt 4 bytes */
25+
unsigned long crc; /* crc-32 4 bytes */
26+
uint64_t compressed_size; /* compressed size 4 bytes */
27+
uint64_t uncompressed_size; /* uncompressed size 4 bytes */
28+
unsigned long size_filename; /* filename length 2 bytes */
29+
unsigned long size_file_extra; /* extra field length 2 bytes */
30+
unsigned long size_file_comment; /* file comment length 2 bytes */
31+
32+
unsigned long disk_num_start; /* disk number start 2 bytes */
33+
unsigned long internal_fa; /* internal file attributes 2 bytes */
34+
unsigned long external_fa; /* external file attributes 4 bytes */
35+
36+
// [ZipArchive] disabled: we don't need the tmu_date field because we already set the dos_date field
37+
// tm_unz tmu_date;
38+
39+
/* minizip-ng fields */
40+
uint64_t disk_offset;
41+
} unz_file_info;
42+
43+
#endif
795 Bytes
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
framework module SSZipArchive {
2+
umbrella header "SSZipArchive-iOS-umbrella.h"
3+
4+
export *
5+
module * { export * }
6+
}
1.3 MB
Binary file not shown.
770 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)