Compare commits
70 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98eeb1a862 | ||
|
|
18703ddb15 | ||
|
|
fc6123aae5 | ||
|
|
4aa70f4237 | ||
|
|
4aaec09339 | ||
|
|
6614014ecc | ||
|
|
ea2f4fc321 | ||
|
|
e451317de6 | ||
|
|
05789bd171 | ||
|
|
451fadc9be | ||
|
|
98c0fbf084 | ||
|
|
032173ba3d | ||
|
|
c063640a55 | ||
|
|
23db0c4b7d | ||
|
|
e3fdfed61a | ||
|
|
83e12647c7 | ||
|
|
bca3071c70 | ||
|
|
841fd2ea2e | ||
|
|
005717dcd9 | ||
|
|
aaaf20c60b | ||
|
|
965e97dab4 | ||
|
|
2df54985de | ||
|
|
244d20f17f | ||
|
|
06da04803a | ||
|
|
1a9738db0e | ||
|
|
8e7cc4eeaa | ||
|
|
5869cd2f6f | ||
|
|
85e38f376e | ||
|
|
a7a9c28973 | ||
|
|
e4697c5a66 | ||
|
|
eeded9e86d | ||
|
|
421c1b4ccc | ||
|
|
f0a9965fa7 | ||
|
|
34101c011b | ||
|
|
37f21d93d0 | ||
|
|
b99e680aaf | ||
|
|
96b49ffae5 | ||
|
|
f87799f92c | ||
|
|
2ca4264756 | ||
|
|
2e975c2895 | ||
|
|
84a96fc298 | ||
|
|
57ea2842ac | ||
|
|
c8eee45526 | ||
|
|
02248d8d04 | ||
|
|
a363be72d7 | ||
|
|
5d903ee581 | ||
|
|
254172f351 | ||
|
|
d7751a54f5 | ||
|
|
58cd06b7d8 | ||
|
|
4fcec5bf76 | ||
|
|
4a2bc37c7a | ||
|
|
7bac3fb757 | ||
|
|
97cd6424fd | ||
|
|
0c98af7f9e | ||
|
|
3952b05eb3 | ||
|
|
54e447185d | ||
|
|
73fb2132a8 | ||
|
|
39ebc12bc8 | ||
|
|
a13812407b | ||
|
|
df48275b02 | ||
|
|
46ebe69295 | ||
|
|
c08241ef19 | ||
|
|
76ca4b3293 | ||
|
|
2ad2d02a81 | ||
|
|
ab77a21ffc | ||
|
|
96577a06c8 | ||
|
|
39b3500120 | ||
|
|
f4c0147086 | ||
|
|
9dae2eca4a | ||
|
|
650c6fb0ab |
@@ -1,7 +1,7 @@
|
||||
language: objective-c
|
||||
osx_image: xcode7.2
|
||||
osx_image: xcode8.2
|
||||
podfile: ObjectiveCExample/Podfile
|
||||
xcode_workspace: ObjectiveCExample/ObjectiveCExample.xcworkspace
|
||||
xcode_scheme: ObjectiveCExample
|
||||
script:
|
||||
- xctool -workspace ObjectiveCExample/ObjectiveCExample.xcworkspace -scheme ObjectiveCExample -sdk iphonesimulator clean test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
|
||||
script: xcodebuild -workspace ObjectiveCExample/ObjectiveCExample.xcworkspace -scheme ObjectiveCExample -sdk iphonesimulator -destination "id=E40727B3-41FB-4D6E-B4CB-BFA87109EB12" -configuration Debug ONLY_ACTIVE_ARCH=NO ENABLE_TESTABILITY=YES test
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@
|
||||
8DFE19E21BDA9FF300709011 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0710;
|
||||
LastUpgradeCheck = 0820;
|
||||
TargetAttributes = {
|
||||
8DFE19E91BDA9FF300709011 = {
|
||||
CreatedOnToolsVersion = 7.1;
|
||||
@@ -488,8 +488,10 @@
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
@@ -532,8 +534,10 @@
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0730"
|
||||
LastUpgradeVersion = "0820"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
9
ObjectiveCExample/ObjectiveCExample/Sample Data/1.md
Executable file
9
ObjectiveCExample/ObjectiveCExample/Sample Data/1.md
Executable file
@@ -0,0 +1,9 @@
|
||||
# 1
|
||||
|
||||
** This is a test **
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non ex turpis. Quisque quis porttitor nunc, sed sollicitudin urna. Aliquam ullamcorper ante fringilla ipsum feugiat egestas. Praesent a dapibus nisi. Proin dignissim non elit sit amet vestibulum. Proin et velit sit amet eros pretium maximus. Suspendisse potenti. Integer dolor felis, vehicula a ipsum vel, faucibus sodales nunc. Nam luctus nunc at malesuada pretium. Suspendisse nec leo in massa ultricies euismod at sed tortor. Nullam eleifend massa eget ultrices sollicitudin. Praesent id dolor vestibulum, mattis nisi ac, semper mi. Aenean justo dui, sollicitudin ut cursus eu, bibendum quis purus. Duis nec nisl augue.
|
||||
|
||||
In et leo in lacus ultricies congue. Sed quis erat ex. Proin tristique leo tincidunt justo hendrerit luctus. Nam mattis fringilla sapien a tincidunt. Nulla ultricies ut ex ac imperdiet. Proin tristique sit amet est nec facilisis. Donec rutrum mauris a pellentesque mollis. Cras blandit arcu at sem vulputate commodo. Mauris ipsum massa, hendrerit vitae cursus sed, malesuada at augue. Aenean nec nisi purus. In lacus mi, luctus id mattis vitae, lacinia sit amet mi. Mauris mollis convallis velit vel vestibulum. Praesent scelerisque eros tellus, sit amet varius massa eleifend et. Duis quis vehicula nisi, vel ultrices mi. Duis eu ipsum ac lorem dignissim semper vel sed nulla.
|
||||
|
||||
Aenean tempus placerat aliquam. Nam accumsan sapien eu ex pretium ullamcorper. Fusce ac risus tortor. Praesent gravida ultricies magna eu aliquam. Nam facilisis lobortis ante vitae imperdiet. Pellentesque metus quam, fermentum sed posuere sed, iaculis in tellus. Donec consequat dui vel nibh mollis porta. Proin sit amet consectetur nisl. Integer tellus justo, imperdiet commodo est at, condimentum viverra est. Maecenas nec erat pharetra, laoreet odio non, rhoncus felis. Curabitur id ex aliquam, mattis massa quis, facilisis ex.
|
||||
7
ObjectiveCExample/ObjectiveCExample/Sample Data/2.md
Executable file
7
ObjectiveCExample/ObjectiveCExample/Sample Data/2.md
Executable file
@@ -0,0 +1,7 @@
|
||||
# Test # 2
|
||||
|
||||
** This is a second test file **
|
||||
|
||||
Morbi vel metus quis lorem tincidunt tempus sit amet quis magna. Nullam dolor dolor, eleifend in vestibulum nec, auctor at ipsum. Nullam viverra neque eros, a vehicula lacus tempus vitae. In sapien sapien, gravida mollis lectus sed, luctus egestas massa. Donec mollis tortor sit amet erat gravida ornare at sed felis. In ornare posuere velit, quis ultrices velit porta eget. Proin eu ultrices felis, eu finibus dolor. Quisque ultrices id libero at euismod. Sed mollis lacus id leo dignissim condimentum eget ac nunc. Vestibulum sed congue velit. Curabitur semper non lorem vel cursus. Ut sed augue purus. Sed sit amet faucibus ante, vel blandit justo. Duis id lacinia ex. Nullam pulvinar eget lacus in tristique. Nam et odio consequat, vehicula mauris ut, vulputate mi.
|
||||
|
||||
Pellentesque feugiat, nulla in dictum lacinia, risus sapien aliquam magna, vitae efficitur neque mauris sagittis neque. Etiam eu hendrerit erat. Vestibulum aliquet sapien sed fermentum ultricies. Maecenas eu risus nec turpis semper consequat. Cras nisl diam, consequat ut orci nec, rutrum cursus est. Quisque dictum nunc leo, lobortis lacinia nisl ultrices eget. Ut imperdiet eu libero quis blandit. Nunc blandit, leo quis rutrum auctor, ex tortor vehicula sem, eu ultrices ipsum mi vel arcu. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
|
||||
@@ -1,9 +0,0 @@
|
||||
# China to ban ivory trade
|
||||
|
||||
**HONG KONG** — It could be the beginning of the end for the illicit trade in ivory.
|
||||
|
||||
Last month, on a state visit to Washington, Chinese President Xi Jinping promised to stop the commercial trade in ivory in his country but gave few details about the timing and extent of such a move.
|
||||
|
||||
Now, a senior U.S. government official says that the Chinese ban could be in place within a year or so, with very narrow exceptions, describing it as a “huge” deal.
|
||||
|
||||
Such a move, conservationists say, would be a major step toward ending the poaching crisis that is decimating Africa’s elephant herds.
|
||||
@@ -1,9 +0,0 @@
|
||||
# Kerry in Syria
|
||||
|
||||
**VIENNA** — The war raging in Syria took center stage for Secretary of State John F. Kerry on Friday as he kicked off a series of meetings with diplomats seeking common ground on a strategy to resolve the grinding conflict.
|
||||
|
||||
But the foreign ministers of the three countries meeting with Kerry — Russia, Saudi Arabia and NATO-member Turkey — carry sharply competing views on how to proceed.
|
||||
|
||||
Saudi Arabia and Turkey, the neighboring country that has been overwhelmed with Syrian refugees, agree with Washington that Syrian President Bashar Al-Assad should eventually leave power.
|
||||
|
||||
Moscow is one of Assad’s biggest backers, and in recent weeks has positioned its military in Syria and conducted heavy airstrikes that have allowed Assad’s forces to resume ground offensives. The Russian military intervention also has alarmed the Pentagon, which is leading a separate air campaign against the Islamic State.
|
||||
BIN
ObjectiveCExample/ObjectiveCExample/Sample Data/mountain.png
Normal file
BIN
ObjectiveCExample/ObjectiveCExample/Sample Data/mountain.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 MiB |
@@ -23,7 +23,7 @@
|
||||
@implementation CancelDelegate
|
||||
- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo
|
||||
{
|
||||
_numFilesUnzipped = fileIndex + 1;
|
||||
_numFilesUnzipped = (int)fileIndex + 1;
|
||||
}
|
||||
- (BOOL)zipArchiveShouldUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo
|
||||
{
|
||||
@@ -173,7 +173,38 @@
|
||||
XCTAssertTrue([fileManager fileExistsAtPath:testPath], @"LICENSE unzipped");
|
||||
}
|
||||
|
||||
- (void)testPasswordCheck {
|
||||
- (void)testUnzippingWithInvalidPassword {
|
||||
NSString *zipPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestPasswordArchive" ofType:@"zip"];
|
||||
NSString *outputPath = [self _cachesPath:@"Password"];
|
||||
|
||||
NSError *error = nil;
|
||||
[SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath overwrite:YES password:@"passw0rd123" error:&error delegate:self];
|
||||
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSString *testPath = [outputPath stringByAppendingPathComponent:@"Readme.markdown"];
|
||||
XCTAssertFalse([fileManager fileExistsAtPath:testPath], @"Readme not unzipped");
|
||||
|
||||
testPath = [outputPath stringByAppendingPathComponent:@"LICENSE"];
|
||||
XCTAssertFalse([fileManager fileExistsAtPath:testPath], @"LICENSE not unzipped");
|
||||
}
|
||||
|
||||
|
||||
- (void)testIsPasswordInvalidForArchiveAtPath {
|
||||
NSString *zipPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestPasswordArchive" ofType:@"zip"];
|
||||
|
||||
NSError *error = nil;
|
||||
|
||||
BOOL fileHasValidPassword = [SSZipArchive isPasswordValidForArchiveAtPath:zipPath password:@"passw0rd" error:&error];
|
||||
|
||||
XCTAssertTrue(fileHasValidPassword,@"Valid password reports false.");
|
||||
|
||||
BOOL fileHasInvalidValidPassword = [SSZipArchive isPasswordValidForArchiveAtPath:zipPath password:@"passw0rd123" error:&error];
|
||||
|
||||
XCTAssertFalse(fileHasInvalidValidPassword,@"Invalid password reports true.");
|
||||
|
||||
}
|
||||
|
||||
- (void)testIsFilePasswordProtectedAtPath {
|
||||
NSString *zipPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestArchive" ofType:@"zip"];
|
||||
|
||||
BOOL protected = [SSZipArchive isFilePasswordProtectedAtPath:zipPath];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
PODS:
|
||||
- SSZipArchive (1.6)
|
||||
- SSZipArchive (1.7)
|
||||
|
||||
DEPENDENCIES:
|
||||
- SSZipArchive (from `..`)
|
||||
@@ -9,8 +9,8 @@ EXTERNAL SOURCES:
|
||||
:path: ".."
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
SSZipArchive: e3560652173f5fe708a835632e63e38b9000bdb7
|
||||
SSZipArchive: 63f8e11cfcc33e03e4cd666b4359ea8bd6facd0c
|
||||
|
||||
PODFILE CHECKSUM: ae5fb993e5dc339b15e10067d1e60549fa585f32
|
||||
|
||||
COCOAPODS: 1.1.0.rc.1
|
||||
COCOAPODS: 1.2.0
|
||||
|
||||
@@ -14,6 +14,8 @@ ZipArchive is a simple utility class for zipping and unzipping files on iOS and
|
||||
|
||||
## Installation and Setup
|
||||
|
||||
*The main release branch is configured to support Objective C and Swift 3. There is a 'swift23' branch which is the latest branch but marked to compile for Swift 2.3.*
|
||||
|
||||
### CocoaPods
|
||||
|
||||
`pod install SSZipArchive`
|
||||
@@ -40,9 +42,7 @@ SSZipArchive requires ARC.
|
||||
[SSZipArchive unzipFileAtPath:zipPath toDestination: unzipPath];
|
||||
```
|
||||
|
||||
### Swift (Swift 3 Only)
|
||||
|
||||
(For Swift 2.3 and below support please use continue to use version 1.4 or 1.5)
|
||||
### Swift
|
||||
|
||||
```swift
|
||||
// Create
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'SSZipArchive'
|
||||
s.version = '1.6'
|
||||
s.version = '1.7'
|
||||
s.summary = 'Utility class for zipping and unzipping files on iOS, tvOS, watchOS, and Mac.'
|
||||
s.description = 'SSZipArchive is a simple utility class for zipping and unzipping files on iOS, tvOS, watchOS, and Mac.'
|
||||
s.homepage = 'https://github.com/ZipArchive/ZipArchive'
|
||||
|
||||
@@ -14,12 +14,21 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern NSString *const SSZipArchiveErrorDomain;
|
||||
typedef NS_ENUM(NSInteger, SSZipArchiveErrorCode) {
|
||||
SSZipArchiveErrorCodeFailedOpenZipFile = -1,
|
||||
SSZipArchiveErrorCodeFailedOpenFirstFile = -2,
|
||||
SSZipArchiveErrorCodeFileInfoNotLoadable = -3,
|
||||
SSZipArchiveErrorCodeFileContentNotReadable = -4,
|
||||
};
|
||||
|
||||
@protocol SSZipArchiveDelegate;
|
||||
|
||||
@interface SSZipArchive : NSObject
|
||||
|
||||
// Password check
|
||||
+ (BOOL)isFilePasswordProtectedAtPath:(NSString *)path;
|
||||
+ (BOOL)isPasswordValidForArchiveAtPath:(NSString *)path password:(NSString *)pw error:(NSError * __nullable * __nullable)error NS_SWIFT_NOTHROW;
|
||||
|
||||
// Unzip
|
||||
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination;
|
||||
@@ -39,14 +48,14 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
+ (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;
|
||||
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError * __nullable error))completionHandler;
|
||||
|
||||
+ (BOOL)unzipFileAtPath:(NSString *)path
|
||||
toDestination:(NSString *)destination
|
||||
overwrite:(BOOL)overwrite
|
||||
password:(nullable NSString *)password
|
||||
progressHandler:(void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
|
||||
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError *error))completionHandler;
|
||||
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError * __nullable error))completionHandler;
|
||||
|
||||
// Zip
|
||||
|
||||
@@ -60,6 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
+ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths withPassword:(nullable NSString *)password;
|
||||
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath withPassword:(nullable NSString *)password;
|
||||
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password;
|
||||
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password andProgressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler;
|
||||
|
||||
- (instancetype)initWithPath:(NSString *)path;
|
||||
@property (NS_NONATOMIC_IOSONLY, readonly) BOOL open;
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
NSString *const SSZipArchiveErrorDomain = @"SSZipArchiveErrorDomain";
|
||||
|
||||
#define CHUNK 16384
|
||||
|
||||
@interface SSZipArchive ()
|
||||
@@ -30,7 +32,7 @@
|
||||
|
||||
+ (BOOL)isFilePasswordProtectedAtPath:(NSString *)path {
|
||||
// Begin opening
|
||||
zipFile zip = unzOpen((const char*)[path UTF8String]);
|
||||
zipFile zip = unzOpen((const char*)[path fileSystemRepresentation]);
|
||||
if (zip == NULL) {
|
||||
return NO;
|
||||
}
|
||||
@@ -39,26 +41,93 @@
|
||||
if (ret == UNZ_OK) {
|
||||
do {
|
||||
ret = unzOpenCurrentFile(zip);
|
||||
if( ret!=UNZ_OK ) {
|
||||
if (ret != UNZ_OK) {
|
||||
return NO;
|
||||
}
|
||||
unz_file_info fileInfo ={0};
|
||||
unz_file_info fileInfo = {0};
|
||||
ret = unzGetCurrentFileInfo(zip, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
|
||||
if (ret!= UNZ_OK) {
|
||||
if (ret != UNZ_OK) {
|
||||
return NO;
|
||||
} else if((fileInfo.flag & 1) == 1) {
|
||||
} else if ((fileInfo.flag & 1) == 1) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
unzCloseCurrentFile(zip);
|
||||
ret = unzGoToNextFile(zip);
|
||||
} while( ret==UNZ_OK && UNZ_OK!=UNZ_END_OF_LIST_OF_FILE );
|
||||
|
||||
} while (ret == UNZ_OK && UNZ_OK != UNZ_END_OF_LIST_OF_FILE);
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (BOOL)isPasswordValidForArchiveAtPath:(NSString *)path password:(NSString *)pw error:(NSError **)error {
|
||||
if (error) {
|
||||
*error = nil;
|
||||
}
|
||||
|
||||
zipFile zip = unzOpen((const char*)[path fileSystemRepresentation]);
|
||||
if (zip == NULL) {
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:SSZipArchiveErrorDomain
|
||||
code:SSZipArchiveErrorCodeFailedOpenZipFile
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"failed to open zip file"}];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
int ret = unzGoToFirstFile(zip);
|
||||
if (ret == UNZ_OK) {
|
||||
do {
|
||||
if ([pw length] == 0) {
|
||||
ret = unzOpenCurrentFile(zip);
|
||||
} else {
|
||||
ret = unzOpenCurrentFilePassword(zip, [pw cStringUsingEncoding:NSASCIIStringEncoding]);
|
||||
}
|
||||
if (ret != UNZ_OK) {
|
||||
if (ret != UNZ_BADPASSWORD) {
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:SSZipArchiveErrorDomain
|
||||
code:SSZipArchiveErrorCodeFailedOpenFirstFile
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"failed to open first file in zip file"}];
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
unz_file_info fileInfo = {0};
|
||||
ret = unzGetCurrentFileInfo(zip, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
|
||||
if (ret != UNZ_OK) {
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:SSZipArchiveErrorDomain
|
||||
code:SSZipArchiveErrorCodeFileInfoNotLoadable
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"failed to retrieve info for file"}];
|
||||
}
|
||||
return NO;
|
||||
} else if ((fileInfo.flag & 1) == 1) {
|
||||
unsigned char buffer[10] = {0};
|
||||
int readBytes = unzReadCurrentFile(zip, buffer, (unsigned)MIN(10UL,fileInfo.uncompressed_size));
|
||||
if (readBytes < 0) {
|
||||
// Let's assume the invalid password caused this error
|
||||
if (readBytes != Z_DATA_ERROR) {
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:SSZipArchiveErrorDomain
|
||||
code:SSZipArchiveErrorCodeFileContentNotReadable
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"failed to read contents of file entry"}];
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
unzCloseCurrentFile(zip);
|
||||
ret = unzGoToNextFile(zip);
|
||||
} while (ret == UNZ_OK && UNZ_OK != UNZ_END_OF_LIST_OF_FILE);
|
||||
}
|
||||
|
||||
// No password required
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark - Unzipping
|
||||
|
||||
+ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination
|
||||
@@ -86,7 +155,7 @@
|
||||
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
|
||||
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError *__nullable error))completionHandler
|
||||
{
|
||||
return [self unzipFileAtPath:path toDestination:destination preserveAttributes:YES overwrite:overwrite password:password error:nil delegate:nil progressHandler:progressHandler completionHandler:completionHandler];
|
||||
}
|
||||
@@ -94,7 +163,7 @@
|
||||
+ (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
|
||||
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError * __nullable error))completionHandler
|
||||
{
|
||||
return [self unzipFileAtPath:path toDestination:destination preserveAttributes:YES overwrite:YES password:nil error:nil delegate:nil progressHandler:progressHandler completionHandler:completionHandler];
|
||||
}
|
||||
@@ -118,14 +187,14 @@
|
||||
error:(NSError **)error
|
||||
delegate:(id<SSZipArchiveDelegate>)delegate
|
||||
progressHandler:(void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
|
||||
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError *error))completionHandler
|
||||
completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError * __nullable error))completionHandler
|
||||
{
|
||||
// Begin opening
|
||||
zipFile zip = unzOpen((const char*)[path UTF8String]);
|
||||
zipFile zip = unzOpen((const char*)[path fileSystemRepresentation]);
|
||||
if (zip == NULL)
|
||||
{
|
||||
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"failed to open zip file"};
|
||||
NSError *err = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:-1 userInfo:userInfo];
|
||||
NSError *err = [NSError errorWithDomain:SSZipArchiveErrorDomain code:SSZipArchiveErrorCodeFailedOpenZipFile userInfo:userInfo];
|
||||
if (error)
|
||||
{
|
||||
*error = err;
|
||||
@@ -148,7 +217,7 @@
|
||||
if (unzGoToFirstFile(zip) != UNZ_OK)
|
||||
{
|
||||
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"failed to open first file in zip file"};
|
||||
NSError *err = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:-2 userInfo:userInfo];
|
||||
NSError *err = [NSError errorWithDomain:SSZipArchiveErrorDomain code:SSZipArchiveErrorCodeFailedOpenFirstFile userInfo:userInfo];
|
||||
if (error)
|
||||
{
|
||||
*error = err;
|
||||
@@ -163,7 +232,7 @@
|
||||
BOOL success = YES;
|
||||
BOOL canceled = NO;
|
||||
int ret = 0;
|
||||
int crc_ret =0;
|
||||
int crc_ret = 0;
|
||||
unsigned char buffer[4096] = {0};
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSMutableArray *directoriesModificationDates = [[NSMutableArray alloc] init];
|
||||
@@ -187,6 +256,7 @@
|
||||
}
|
||||
|
||||
if (ret != UNZ_OK) {
|
||||
unzippingError = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:-2 userInfo:@{NSLocalizedDescriptionKey: @"failed to open file in zip file"}];
|
||||
success = NO;
|
||||
break;
|
||||
}
|
||||
@@ -197,6 +267,7 @@
|
||||
|
||||
ret = unzGetCurrentFileInfo(zip, &fileInfo, NULL, 0, NULL, 0, NULL, 0);
|
||||
if (ret != UNZ_OK) {
|
||||
unzippingError = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:-3 userInfo:@{NSLocalizedDescriptionKey: @"failed to retrieve info for file"}];
|
||||
success = NO;
|
||||
unzCloseCurrentFile(zip);
|
||||
break;
|
||||
@@ -225,7 +296,8 @@
|
||||
char *filename = (char *)malloc(fileInfo.size_filename + 1);
|
||||
if (filename == NULL)
|
||||
{
|
||||
return NO;
|
||||
success = NO;
|
||||
break;
|
||||
}
|
||||
|
||||
unzGetCurrentFileInfo(zip, &fileInfo, filename, fileInfo.size_filename + 1, NULL, 0, NULL, 0);
|
||||
@@ -272,16 +344,7 @@
|
||||
strPath = [strPath stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
|
||||
}
|
||||
|
||||
NSString *fullPath;
|
||||
BOOL isDir = NO;
|
||||
if([[NSFileManager defaultManager]
|
||||
fileExistsAtPath:destination isDirectory:&isDir] && isDir){
|
||||
fullPath = [destination stringByAppendingPathComponent:strPath];
|
||||
}
|
||||
else {
|
||||
fullPath = destination;
|
||||
}
|
||||
|
||||
NSString *fullPath = [destination stringByAppendingPathComponent:strPath];
|
||||
NSError *err = nil;
|
||||
NSDictionary *directoryAttr;
|
||||
if (preserveAttributes) {
|
||||
@@ -313,77 +376,80 @@
|
||||
}
|
||||
|
||||
if (!fileIsSymbolicLink) {
|
||||
FILE *fp = fopen((const char*)[fullPath UTF8String], "wb");
|
||||
while (fp) {
|
||||
int readBytes = unzReadCurrentFile(zip, buffer, 4096);
|
||||
|
||||
if (readBytes > 0) {
|
||||
fwrite(buffer, readBytes, 1, fp );
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fp) {
|
||||
if ([[[fullPath pathExtension] lowercaseString] isEqualToString:@"zip"]) {
|
||||
NSLog(@"Unzipping nested .zip file: %@", [fullPath lastPathComponent]);
|
||||
if ([self unzipFileAtPath:fullPath toDestination:[fullPath stringByDeletingLastPathComponent] overwrite:overwrite password:password error:nil delegate:nil ]) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:fullPath error:nil];
|
||||
// ensure we are not creating stale file entries
|
||||
int readBytes = unzReadCurrentFile(zip, buffer, 4096);
|
||||
if (readBytes >= 0) {
|
||||
FILE *fp = fopen((const char*)[fullPath fileSystemRepresentation], "wb");
|
||||
while (fp) {
|
||||
if (readBytes > 0) {
|
||||
fwrite(buffer, readBytes, 1, fp);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
readBytes = unzReadCurrentFile(zip, buffer, 4096);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if (preserveAttributes) {
|
||||
|
||||
// Set the original datetime property
|
||||
if (fileInfo.dosDate != 0) {
|
||||
NSDate *orgDate = [[self class] _dateWithMSDOSFormat:(UInt32)fileInfo.dosDate];
|
||||
NSDictionary *attr = @{NSFileModificationDate: orgDate};
|
||||
|
||||
if (attr) {
|
||||
if ([fileManager setAttributes:attr ofItemAtPath:fullPath error:nil] == NO) {
|
||||
// Can't set attributes
|
||||
NSLog(@"[SSZipArchive] Failed to set attributes - whilst setting modification date");
|
||||
if (fp) {
|
||||
if ([[[fullPath pathExtension] lowercaseString] isEqualToString:@"zip"]) {
|
||||
NSLog(@"Unzipping nested .zip file: %@", [fullPath lastPathComponent]);
|
||||
if ([self unzipFileAtPath:fullPath toDestination:[fullPath stringByDeletingLastPathComponent] overwrite:overwrite password:password error:nil delegate:nil]) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:fullPath error:nil];
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if (preserveAttributes) {
|
||||
|
||||
// Set the original datetime property
|
||||
if (fileInfo.dosDate != 0) {
|
||||
NSDate *orgDate = [[self class] _dateWithMSDOSFormat:(UInt32)fileInfo.dosDate];
|
||||
NSDictionary *attr = @{NSFileModificationDate: orgDate};
|
||||
|
||||
if (attr) {
|
||||
if ([fileManager setAttributes:attr ofItemAtPath:fullPath error:nil] == NO) {
|
||||
// Can't set attributes
|
||||
NSLog(@"[SSZipArchive] Failed to set attributes - whilst setting modification date");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the original permissions on the file
|
||||
uLong permissions = fileInfo.external_fa >> 16;
|
||||
if (permissions != 0) {
|
||||
// Store it into a NSNumber
|
||||
NSNumber *permissionsValue = @(permissions);
|
||||
|
||||
// Retrieve any existing attributes
|
||||
NSMutableDictionary *attrs = [[NSMutableDictionary alloc] initWithDictionary:[fileManager attributesOfItemAtPath:fullPath error:nil]];
|
||||
// Set the original permissions on the file
|
||||
uLong permissions = fileInfo.external_fa >> 16;
|
||||
if (permissions != 0) {
|
||||
// Store it into a NSNumber
|
||||
NSNumber *permissionsValue = @(permissions);
|
||||
|
||||
// Set the value in the attributes dict
|
||||
attrs[NSFilePosixPermissions] = permissionsValue;
|
||||
// Retrieve any existing attributes
|
||||
NSMutableDictionary *attrs = [[NSMutableDictionary alloc] initWithDictionary:[fileManager attributesOfItemAtPath:fullPath error:nil]];
|
||||
|
||||
// Update attributes
|
||||
if ([fileManager setAttributes:attrs ofItemAtPath:fullPath error:nil] == NO) {
|
||||
// Unable to set the permissions attribute
|
||||
NSLog(@"[SSZipArchive] Failed to set attributes - whilst setting permissions");
|
||||
}
|
||||
// Set the value in the attributes dict
|
||||
attrs[NSFilePosixPermissions] = permissionsValue;
|
||||
|
||||
// Update attributes
|
||||
if ([fileManager setAttributes:attrs ofItemAtPath:fullPath error:nil] == NO) {
|
||||
// Unable to set the permissions attribute
|
||||
NSLog(@"[SSZipArchive] Failed to set attributes - whilst setting permissions");
|
||||
}
|
||||
|
||||
#if !__has_feature(objc_arc)
|
||||
[attrs release];
|
||||
[attrs release];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we couldn't open file descriptor we can validate global errno to see the reason
|
||||
if (errno == ENOSPC) {
|
||||
NSError *enospcError = [NSError errorWithDomain:NSPOSIXErrorDomain
|
||||
code:ENOSPC
|
||||
userInfo:nil];
|
||||
unzippingError = enospcError;
|
||||
unzCloseCurrentFile(zip);
|
||||
success = NO;
|
||||
break;
|
||||
else
|
||||
{
|
||||
// if we couldn't open file descriptor we can validate global errno to see the reason
|
||||
if (errno == ENOSPC) {
|
||||
NSError *enospcError = [NSError errorWithDomain:NSPOSIXErrorDomain
|
||||
code:ENOSPC
|
||||
userInfo:nil];
|
||||
unzippingError = enospcError;
|
||||
unzCloseCurrentFile(zip);
|
||||
success = NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -392,7 +458,7 @@
|
||||
// Assemble the path for the symbolic link
|
||||
NSMutableString* destinationPath = [NSMutableString string];
|
||||
int bytesRead = 0;
|
||||
while((bytesRead = unzReadCurrentFile(zip, buffer, 4096)) > 0)
|
||||
while ((bytesRead = unzReadCurrentFile(zip, buffer, 4096)) > 0)
|
||||
{
|
||||
buffer[bytesRead] = (int)0;
|
||||
[destinationPath appendString:@((const char*)buffer)];
|
||||
@@ -402,19 +468,19 @@
|
||||
int symlinkError = symlink([destinationPath cStringUsingEncoding:NSUTF8StringEncoding],
|
||||
[fullPath cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
|
||||
if(symlinkError != 0)
|
||||
if (symlinkError != 0)
|
||||
{
|
||||
NSLog(@"Failed to create symbolic link at \"%@\" to \"%@\". symlink() error code: %d", fullPath, destinationPath, errno);
|
||||
}
|
||||
}
|
||||
|
||||
crc_ret = unzCloseCurrentFile( zip );
|
||||
crc_ret = unzCloseCurrentFile(zip);
|
||||
if (crc_ret == UNZ_CRCERROR) {
|
||||
//CRC ERROR
|
||||
success = NO;
|
||||
break;
|
||||
}
|
||||
ret = unzGoToNextFile( zip );
|
||||
ret = unzGoToNextFile(zip);
|
||||
|
||||
// Message delegate
|
||||
if ([delegate respondsToSelector:@selector(zipArchiveDidUnzipFileAtIndex:totalFiles:archivePath:fileInfo:)]) {
|
||||
@@ -431,7 +497,7 @@
|
||||
progressHandler(strPath, fileInfo, currentFileNumber, globalInfo.number_entry);
|
||||
}
|
||||
}
|
||||
} while(ret == UNZ_OK && ret != UNZ_END_OF_LIST_OF_FILE);
|
||||
} while (ret == UNZ_OK && ret != UNZ_END_OF_LIST_OF_FILE);
|
||||
|
||||
// Close
|
||||
unzClose(zip);
|
||||
@@ -467,7 +533,7 @@
|
||||
if (crc_ret == UNZ_CRCERROR)
|
||||
{
|
||||
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"crc check failed for file"};
|
||||
retErr = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:-3 userInfo:userInfo];
|
||||
retErr = [NSError errorWithDomain:SSZipArchiveErrorDomain code:SSZipArchiveErrorCodeFileInfoNotLoadable userInfo:userInfo];
|
||||
}
|
||||
|
||||
if (error) {
|
||||
@@ -523,11 +589,20 @@
|
||||
}
|
||||
|
||||
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath withPassword:(nullable NSString *)password{
|
||||
return [self createZipFileAtPath:path withContentsOfDirectory:directoryPath keepParentDirectory:NO withPassword:password];
|
||||
return [SSZipArchive createZipFileAtPath:path withContentsOfDirectory:directoryPath keepParentDirectory:NO withPassword:password];
|
||||
}
|
||||
|
||||
|
||||
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password{
|
||||
return [SSZipArchive createZipFileAtPath:path
|
||||
withContentsOfDirectory:directoryPath
|
||||
keepParentDirectory:keepParentDirectory
|
||||
withPassword:password
|
||||
andProgressHandler:nil
|
||||
];
|
||||
}
|
||||
|
||||
+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password andProgressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler {
|
||||
BOOL success = NO;
|
||||
|
||||
NSFileManager *fileManager = nil;
|
||||
@@ -537,8 +612,10 @@
|
||||
// use a local filemanager (queue/thread compatibility)
|
||||
fileManager = [[NSFileManager alloc] init];
|
||||
NSDirectoryEnumerator *dirEnumerator = [fileManager enumeratorAtPath:directoryPath];
|
||||
NSArray *allObjects = dirEnumerator.allObjects;
|
||||
NSUInteger total = allObjects.count, complete = 0;
|
||||
NSString *fileName;
|
||||
while ((fileName = [dirEnumerator nextObject])) {
|
||||
for (fileName in allObjects) {
|
||||
BOOL isDir;
|
||||
NSString *fullFilePath = [directoryPath stringByAppendingPathComponent:fileName];
|
||||
[fileManager fileExistsAtPath:fullFilePath isDirectory:&isDir];
|
||||
@@ -553,13 +630,17 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
if([[NSFileManager defaultManager] subpathsOfDirectoryAtPath:fullFilePath error:nil].count == 0)
|
||||
if ([[NSFileManager defaultManager] subpathsOfDirectoryAtPath:fullFilePath error:nil].count == 0)
|
||||
{
|
||||
NSString *tempFilePath = [self _temporaryPathForDiscardableFile];
|
||||
NSString *tempFileFilename = [fileName stringByAppendingPathComponent:tempFilePath.lastPathComponent];
|
||||
[zipArchive writeFileAtPath:tempFilePath withFileName:tempFileFilename withPassword:password];
|
||||
}
|
||||
}
|
||||
complete++;
|
||||
if (progressHandler) {
|
||||
progressHandler(complete, total);
|
||||
}
|
||||
}
|
||||
success = [zipArchive close];
|
||||
}
|
||||
@@ -594,7 +675,7 @@
|
||||
- (BOOL)open
|
||||
{
|
||||
NSAssert((_zip == NULL), @"Attempting open an archive which is already open");
|
||||
_zip = zipOpen([_path UTF8String], APPEND_STATUS_CREATE);
|
||||
_zip = zipOpen([_path fileSystemRepresentation], APPEND_STATUS_CREATE);
|
||||
return (NULL != _zip);
|
||||
}
|
||||
|
||||
@@ -623,12 +704,12 @@
|
||||
zip_fileinfo zipInfo = {{0}};
|
||||
|
||||
NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:path error: nil];
|
||||
if( attr )
|
||||
if (attr)
|
||||
{
|
||||
NSDate *fileDate = (NSDate *)attr[NSFileModificationDate];
|
||||
if( fileDate )
|
||||
if (fileDate)
|
||||
{
|
||||
[self zipInfo:&zipInfo setDate: fileDate ];
|
||||
[self zipInfo:&zipInfo setDate: fileDate];
|
||||
}
|
||||
|
||||
// Write permissions into the external attributes, for details on this see here: http://unix.stackexchange.com/a/14727
|
||||
@@ -650,7 +731,7 @@
|
||||
}
|
||||
|
||||
unsigned int len = 0;
|
||||
zipOpenNewFileInZip3(_zip, [[folderName stringByAppendingString:@"/"] UTF8String], &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_NO_COMPRESSION, 0, -MAX_WBITS, DEF_MEM_LEVEL,
|
||||
zipOpenNewFileInZip3(_zip, [[folderName stringByAppendingString:@"/"] fileSystemRepresentation], &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_NO_COMPRESSION, 0, -MAX_WBITS, DEF_MEM_LEVEL,
|
||||
Z_DEFAULT_STRATEGY, [password UTF8String], 0);
|
||||
zipWriteInFileInZip(_zip, &len, 0);
|
||||
zipCloseFileInZip(_zip);
|
||||
@@ -669,28 +750,28 @@
|
||||
{
|
||||
NSAssert((_zip != NULL), @"Attempting to write to an archive which was never opened");
|
||||
|
||||
FILE *input = fopen([path UTF8String], "r");
|
||||
FILE *input = fopen([path fileSystemRepresentation], "r");
|
||||
if (NULL == input) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
const char *afileName;
|
||||
if (!fileName) {
|
||||
afileName = [path.lastPathComponent UTF8String];
|
||||
afileName = [path.lastPathComponent fileSystemRepresentation];
|
||||
}
|
||||
else {
|
||||
afileName = [fileName UTF8String];
|
||||
afileName = [fileName fileSystemRepresentation];
|
||||
}
|
||||
|
||||
zip_fileinfo zipInfo = {{0}};
|
||||
|
||||
NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:path error: nil];
|
||||
if( attr )
|
||||
if (attr)
|
||||
{
|
||||
NSDate *fileDate = (NSDate *)attr[NSFileModificationDate];
|
||||
if( fileDate )
|
||||
if (fileDate)
|
||||
{
|
||||
[self zipInfo:&zipInfo setDate: fileDate ];
|
||||
[self zipInfo:&zipInfo setDate: fileDate];
|
||||
}
|
||||
|
||||
// Write permissions into the external attributes, for details on this see here: http://unix.stackexchange.com/a/14727
|
||||
@@ -720,7 +801,7 @@
|
||||
zipOpenNewFileInZip3(_zip, afileName, &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION, 0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, [password UTF8String], 0);
|
||||
unsigned int len = 0;
|
||||
|
||||
while (!feof(input))
|
||||
while (!feof(input) && !ferror(input))
|
||||
{
|
||||
len = (unsigned int) fread(buffer, 1, CHUNK, input);
|
||||
zipWriteInFileInZip(_zip, buffer, len);
|
||||
@@ -743,7 +824,7 @@
|
||||
zip_fileinfo zipInfo = {{0,0,0,0,0,0},0,0,0};
|
||||
[self zipInfo:&zipInfo setDate:[NSDate date]];
|
||||
|
||||
zipOpenNewFileInZip3(_zip, [filename UTF8String], &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION, 0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, [password UTF8String], 0);
|
||||
zipOpenNewFileInZip3(_zip, [filename fileSystemRepresentation], &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION, 0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, [password UTF8String], 0);
|
||||
|
||||
zipWriteInFileInZip(_zip, data.bytes, (unsigned int)data.length);
|
||||
|
||||
@@ -770,8 +851,10 @@
|
||||
NSString *temporaryDirectoryName = [[NSUUID UUID] UUIDString];
|
||||
NSString *temporaryDirectory = [NSTemporaryDirectory() stringByAppendingPathComponent:temporaryDirectoryName];
|
||||
BOOL directoryCreated = [[NSFileManager defaultManager] createDirectoryAtPath:temporaryDirectory withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
discardableFilePath = directoryCreated ? [temporaryDirectory stringByAppendingPathComponent:discardableFileName] : nil;
|
||||
[@"" writeToFile:discardableFilePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
||||
if (directoryCreated) {
|
||||
discardableFilePath = [temporaryDirectory stringByAppendingPathComponent:discardableFileName];
|
||||
[@"" writeToFile:discardableFilePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
||||
}
|
||||
});
|
||||
return discardableFilePath;
|
||||
}
|
||||
@@ -822,4 +905,4 @@
|
||||
return date;
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
@@ -1190,7 +1190,8 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int *method, int *level, in
|
||||
return UNZ_INTERNALERROR;
|
||||
#ifdef HAVE_AES
|
||||
if (s->cur_file_info.compression_method == AES_METHOD) {
|
||||
unsigned char passverify[AES_PWVERIFYSIZE];
|
||||
unsigned char passverify_archive[AES_PWVERIFYSIZE];
|
||||
unsigned char passverify_password[AES_PWVERIFYSIZE];
|
||||
unsigned char saltvalue[AES_MAXSALTLENGTH];
|
||||
uInt saltlength;
|
||||
|
||||
@@ -1202,11 +1203,14 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int *method, int *level, in
|
||||
|
||||
if (ZREAD64(s->z_filefunc, s->filestream, saltvalue, saltlength) != saltlength)
|
||||
return UNZ_INTERNALERROR;
|
||||
if (ZREAD64(s->z_filefunc, s->filestream, passverify, AES_PWVERIFYSIZE) != AES_PWVERIFYSIZE)
|
||||
if (ZREAD64(s->z_filefunc, s->filestream, passverify_archive, AES_PWVERIFYSIZE) != AES_PWVERIFYSIZE)
|
||||
return UNZ_INTERNALERROR;
|
||||
|
||||
fcrypt_init((int)s->cur_file_info_internal.aes_encryption_mode, (unsigned char *)password, (unsigned int)strlen(password), saltvalue,
|
||||
passverify, &s->pfile_in_zip_read->aes_ctx);
|
||||
fcrypt_init(s->cur_file_info_internal.aes_encryption_mode, password, strlen(password), saltvalue,
|
||||
passverify_password, &s->pfile_in_zip_read->aes_ctx);
|
||||
|
||||
if (memcmp(passverify_archive, passverify_password, AES_PWVERIFYSIZE) != 0)
|
||||
return UNZ_BADPASSWORD;
|
||||
|
||||
pfile_in_zip_read_info->rest_read_compressed -= saltlength + AES_PWVERIFYSIZE;
|
||||
pfile_in_zip_read_info->rest_read_compressed -= AES_AUTHCODESIZE;
|
||||
|
||||
@@ -57,6 +57,7 @@ typedef voidp unzFile;
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
#define UNZ_BADPASSWORD (-106)
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
PODS:
|
||||
- SSZipArchive (1.6)
|
||||
- SSZipArchive (1.7)
|
||||
|
||||
DEPENDENCIES:
|
||||
- SSZipArchive (from `..`)
|
||||
@@ -9,8 +9,8 @@ EXTERNAL SOURCES:
|
||||
:path: ".."
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
SSZipArchive: e3560652173f5fe708a835632e63e38b9000bdb7
|
||||
SSZipArchive: 63f8e11cfcc33e03e4cd666b4359ea8bd6facd0c
|
||||
|
||||
PODFILE CHECKSUM: 8d38f966bef0580b1feb382672c12ef6a674ea58
|
||||
|
||||
COCOAPODS: 1.1.0.rc.1
|
||||
COCOAPODS: 1.1.1
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
2B4B24671C21500E00CC99E5 /* mztools.c in Sources */ = {isa = PBXBuildFile; fileRef = 8DFE19391BDA7D8C00709011 /* mztools.c */; };
|
||||
2B4B24681C21500E00CC99E5 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DFE190E1BDA74F800709011 /* ViewController.swift */; };
|
||||
2B4B24691C21500E00CC99E5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DFE190C1BDA74F800709011 /* AppDelegate.swift */; };
|
||||
2B4B246D1C21500E00CC99E5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8DFE19151BDA74F800709011 /* LaunchScreen.storyboard */; };
|
||||
@@ -21,7 +20,6 @@
|
||||
8DFE19141BDA74F800709011 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8DFE19131BDA74F800709011 /* Assets.xcassets */; };
|
||||
8DFE19171BDA74F800709011 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8DFE19151BDA74F800709011 /* LaunchScreen.storyboard */; };
|
||||
8DFE19221BDA74F800709011 /* SwiftExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DFE19211BDA74F800709011 /* SwiftExampleTests.swift */; };
|
||||
8DFE19421BDA7D8D00709011 /* mztools.c in Sources */ = {isa = PBXBuildFile; fileRef = 8DFE19391BDA7D8C00709011 /* mztools.c */; };
|
||||
8DFE19471BDA82EA00709011 /* Sample Data in Resources */ = {isa = PBXBuildFile; fileRef = 8DFE19461BDA82EA00709011 /* Sample Data */; };
|
||||
9C98C3B4F9B653B83DA9D5F1 /* Pods_SwiftExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B957B9DCEA770A395AA9EF69 /* Pods_SwiftExample.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
@@ -51,18 +49,6 @@
|
||||
8DFE191D1BDA74F800709011 /* SwiftExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8DFE19211BDA74F800709011 /* SwiftExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftExampleTests.swift; sourceTree = "<group>"; };
|
||||
8DFE19231BDA74F800709011 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
8DFE19341BDA7D8C00709011 /* Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Common.h; sourceTree = "<group>"; };
|
||||
8DFE19361BDA7D8C00709011 /* crypt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = crypt.h; sourceTree = "<group>"; };
|
||||
8DFE19371BDA7D8C00709011 /* ioapi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ioapi.c; sourceTree = "<group>"; };
|
||||
8DFE19381BDA7D8C00709011 /* ioapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ioapi.h; sourceTree = "<group>"; };
|
||||
8DFE19391BDA7D8C00709011 /* mztools.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mztools.c; sourceTree = "<group>"; };
|
||||
8DFE193A1BDA7D8C00709011 /* mztools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mztools.h; sourceTree = "<group>"; };
|
||||
8DFE193B1BDA7D8C00709011 /* unzip.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = unzip.c; sourceTree = "<group>"; };
|
||||
8DFE193C1BDA7D8C00709011 /* unzip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unzip.h; sourceTree = "<group>"; };
|
||||
8DFE193D1BDA7D8C00709011 /* zip.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zip.c; sourceTree = "<group>"; };
|
||||
8DFE193E1BDA7D8C00709011 /* zip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zip.h; sourceTree = "<group>"; };
|
||||
8DFE193F1BDA7D8C00709011 /* SSZipArchive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSZipArchive.h; sourceTree = "<group>"; };
|
||||
8DFE19401BDA7D8D00709011 /* SSZipArchive.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSZipArchive.m; sourceTree = "<group>"; };
|
||||
8DFE19461BDA82EA00709011 /* Sample Data */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "Sample Data"; sourceTree = "<group>"; };
|
||||
9F41DD1EB899AECA3DE54836 /* Pods-SwiftExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftExample/Pods-SwiftExample.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
B957B9DCEA770A395AA9EF69 /* Pods_SwiftExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -117,7 +103,6 @@
|
||||
8DFE19001BDA74F800709011 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8DFE19331BDA7D8C00709011 /* SSZipArchive */,
|
||||
8DFE190B1BDA74F800709011 /* SwiftExample */,
|
||||
8DFE19201BDA74F800709011 /* SwiftExampleTests */,
|
||||
8DFE190A1BDA74F800709011 /* Products */,
|
||||
@@ -159,34 +144,6 @@
|
||||
path = SwiftExampleTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8DFE19331BDA7D8C00709011 /* SSZipArchive */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8DFE19341BDA7D8C00709011 /* Common.h */,
|
||||
8DFE193F1BDA7D8C00709011 /* SSZipArchive.h */,
|
||||
8DFE19401BDA7D8D00709011 /* SSZipArchive.m */,
|
||||
8DFE19351BDA7D8C00709011 /* minizip */,
|
||||
);
|
||||
name = SSZipArchive;
|
||||
path = ../SSZipArchive;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8DFE19351BDA7D8C00709011 /* minizip */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8DFE19361BDA7D8C00709011 /* crypt.h */,
|
||||
8DFE19371BDA7D8C00709011 /* ioapi.c */,
|
||||
8DFE19381BDA7D8C00709011 /* ioapi.h */,
|
||||
8DFE19391BDA7D8C00709011 /* mztools.c */,
|
||||
8DFE193A1BDA7D8C00709011 /* mztools.h */,
|
||||
8DFE193B1BDA7D8C00709011 /* unzip.c */,
|
||||
8DFE193C1BDA7D8C00709011 /* unzip.h */,
|
||||
8DFE193D1BDA7D8C00709011 /* zip.c */,
|
||||
8DFE193E1BDA7D8C00709011 /* zip.h */,
|
||||
);
|
||||
path = minizip;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
@@ -257,11 +214,11 @@
|
||||
TargetAttributes = {
|
||||
8DFE19081BDA74F800709011 = {
|
||||
CreatedOnToolsVersion = 7.1;
|
||||
LastSwiftMigration = 0800;
|
||||
LastSwiftMigration = 0820;
|
||||
};
|
||||
8DFE191C1BDA74F800709011 = {
|
||||
CreatedOnToolsVersion = 7.1;
|
||||
LastSwiftMigration = 0800;
|
||||
LastSwiftMigration = 0820;
|
||||
TestTargetID = 8DFE19081BDA74F800709011;
|
||||
};
|
||||
};
|
||||
@@ -386,7 +343,6 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2B4B24671C21500E00CC99E5 /* mztools.c in Sources */,
|
||||
2B4B24681C21500E00CC99E5 /* ViewController.swift in Sources */,
|
||||
2B4B24691C21500E00CC99E5 /* AppDelegate.swift in Sources */,
|
||||
);
|
||||
@@ -396,7 +352,6 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8DFE19421BDA7D8D00709011 /* mztools.c in Sources */,
|
||||
8DFE190F1BDA74F800709011 /* ViewController.swift in Sources */,
|
||||
8DFE190D1BDA74F800709011 /* AppDelegate.swift in Sources */,
|
||||
);
|
||||
@@ -453,6 +408,7 @@
|
||||
OTHER_SWIFT_FLAGS = "-DUseCarthage";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.samsoffes.SwiftExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -469,6 +425,7 @@
|
||||
OTHER_SWIFT_FLAGS = "-DUseCarthage";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.samsoffes.SwiftExample;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<device id="retina5_5" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
@@ -13,10 +18,9 @@
|
||||
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<animations/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
||||
<device id="retina5_5" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
@@ -16,38 +19,44 @@
|
||||
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Uwd-kM-cdh">
|
||||
<rect key="frame" x="150.66666666666669" y="51" width="113.00000000000006" height="30"/>
|
||||
<state key="normal" title="Zip Sample Data"/>
|
||||
<connections>
|
||||
<action selector="zipPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="dQS-RP-2Yl"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XUJ-IR-RIS">
|
||||
<rect key="frame" x="141.66666666666669" y="89" width="131.00000000000006" height="30"/>
|
||||
<state key="normal" title="Unzip Sample Data"/>
|
||||
<connections>
|
||||
<action selector="unzipPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="gGR-nU-aS3"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Lbq-oS-Rlj">
|
||||
<rect key="frame" x="187.66666666666666" y="212.66666666666666" width="39" height="30"/>
|
||||
<state key="normal" title="Reset"/>
|
||||
<connections>
|
||||
<action selector="resetPressed:" destination="BYZ-38-t0r" eventType="touchUpInside" id="n8G-qy-egF"/>
|
||||
</connections>
|
||||
</button>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="09F-6Q-slx" userLabel="File1">
|
||||
<rect key="frame" x="67" y="126.99999999999999" width="294" height="20.666666666666643"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PSK-Jd-Mwc" userLabel="File2">
|
||||
<rect key="frame" x="67" y="155.66666666666663" width="294" height="20.333333333333343"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pW5-rw-iqM" userLabel="File3">
|
||||
<rect key="frame" x="67" y="184" width="294" height="20.666666666666657"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
|
||||
9
SwiftExample/SwiftExample/Sample Data/1.md
Normal file
9
SwiftExample/SwiftExample/Sample Data/1.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# 1
|
||||
|
||||
** This is a test **
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non ex turpis. Quisque quis porttitor nunc, sed sollicitudin urna. Aliquam ullamcorper ante fringilla ipsum feugiat egestas. Praesent a dapibus nisi. Proin dignissim non elit sit amet vestibulum. Proin et velit sit amet eros pretium maximus. Suspendisse potenti. Integer dolor felis, vehicula a ipsum vel, faucibus sodales nunc. Nam luctus nunc at malesuada pretium. Suspendisse nec leo in massa ultricies euismod at sed tortor. Nullam eleifend massa eget ultrices sollicitudin. Praesent id dolor vestibulum, mattis nisi ac, semper mi. Aenean justo dui, sollicitudin ut cursus eu, bibendum quis purus. Duis nec nisl augue.
|
||||
|
||||
In et leo in lacus ultricies congue. Sed quis erat ex. Proin tristique leo tincidunt justo hendrerit luctus. Nam mattis fringilla sapien a tincidunt. Nulla ultricies ut ex ac imperdiet. Proin tristique sit amet est nec facilisis. Donec rutrum mauris a pellentesque mollis. Cras blandit arcu at sem vulputate commodo. Mauris ipsum massa, hendrerit vitae cursus sed, malesuada at augue. Aenean nec nisi purus. In lacus mi, luctus id mattis vitae, lacinia sit amet mi. Mauris mollis convallis velit vel vestibulum. Praesent scelerisque eros tellus, sit amet varius massa eleifend et. Duis quis vehicula nisi, vel ultrices mi. Duis eu ipsum ac lorem dignissim semper vel sed nulla.
|
||||
|
||||
Aenean tempus placerat aliquam. Nam accumsan sapien eu ex pretium ullamcorper. Fusce ac risus tortor. Praesent gravida ultricies magna eu aliquam. Nam facilisis lobortis ante vitae imperdiet. Pellentesque metus quam, fermentum sed posuere sed, iaculis in tellus. Donec consequat dui vel nibh mollis porta. Proin sit amet consectetur nisl. Integer tellus justo, imperdiet commodo est at, condimentum viverra est. Maecenas nec erat pharetra, laoreet odio non, rhoncus felis. Curabitur id ex aliquam, mattis massa quis, facilisis ex.
|
||||
7
SwiftExample/SwiftExample/Sample Data/2.md
Normal file
7
SwiftExample/SwiftExample/Sample Data/2.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Test # 2
|
||||
|
||||
** This is a second test file **
|
||||
|
||||
Morbi vel metus quis lorem tincidunt tempus sit amet quis magna. Nullam dolor dolor, eleifend in vestibulum nec, auctor at ipsum. Nullam viverra neque eros, a vehicula lacus tempus vitae. In sapien sapien, gravida mollis lectus sed, luctus egestas massa. Donec mollis tortor sit amet erat gravida ornare at sed felis. In ornare posuere velit, quis ultrices velit porta eget. Proin eu ultrices felis, eu finibus dolor. Quisque ultrices id libero at euismod. Sed mollis lacus id leo dignissim condimentum eget ac nunc. Vestibulum sed congue velit. Curabitur semper non lorem vel cursus. Ut sed augue purus. Sed sit amet faucibus ante, vel blandit justo. Duis id lacinia ex. Nullam pulvinar eget lacus in tristique. Nam et odio consequat, vehicula mauris ut, vulputate mi.
|
||||
|
||||
Pellentesque feugiat, nulla in dictum lacinia, risus sapien aliquam magna, vitae efficitur neque mauris sagittis neque. Etiam eu hendrerit erat. Vestibulum aliquet sapien sed fermentum ultricies. Maecenas eu risus nec turpis semper consequat. Cras nisl diam, consequat ut orci nec, rutrum cursus est. Quisque dictum nunc leo, lobortis lacinia nisl ultrices eget. Ut imperdiet eu libero quis blandit. Nunc blandit, leo quis rutrum auctor, ex tortor vehicula sem, eu ultrices ipsum mi vel arcu. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
|
||||
@@ -1,9 +0,0 @@
|
||||
# China to ban ivory trade
|
||||
|
||||
**HONG KONG** — It could be the beginning of the end for the illicit trade in ivory.
|
||||
|
||||
Last month, on a state visit to Washington, Chinese President Xi Jinping promised to stop the commercial trade in ivory in his country but gave few details about the timing and extent of such a move.
|
||||
|
||||
Now, a senior U.S. government official says that the Chinese ban could be in place within a year or so, with very narrow exceptions, describing it as a “huge” deal.
|
||||
|
||||
Such a move, conservationists say, would be a major step toward ending the poaching crisis that is decimating Africa’s elephant herds.
|
||||
@@ -1,9 +0,0 @@
|
||||
# Kerry in Syria
|
||||
|
||||
**VIENNA** — The war raging in Syria took center stage for Secretary of State John F. Kerry on Friday as he kicked off a series of meetings with diplomats seeking common ground on a strategy to resolve the grinding conflict.
|
||||
|
||||
But the foreign ministers of the three countries meeting with Kerry — Russia, Saudi Arabia and NATO-member Turkey — carry sharply competing views on how to proceed.
|
||||
|
||||
Saudi Arabia and Turkey, the neighboring country that has been overwhelmed with Syrian refugees, agree with Washington that Syrian President Bashar Al-Assad should eventually leave power.
|
||||
|
||||
Moscow is one of Assad’s biggest backers, and in recent weeks has positioned its military in Syria and conducted heavy airstrikes that have allowed Assad’s forces to resume ground offensives. The Russian military intervention also has alarmed the Pentagon, which is leading a separate air campaign against the Islamic State.
|
||||
BIN
SwiftExample/SwiftExample/Sample Data/mountain.png
Normal file
BIN
SwiftExample/SwiftExample/Sample Data/mountain.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 MiB |
@@ -29,6 +29,10 @@ class ViewController: UIViewController {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
|
||||
file1.text = ""
|
||||
file2.text = ""
|
||||
file3.text = ""
|
||||
}
|
||||
|
||||
override func didReceiveMemoryWarning() {
|
||||
|
||||
@@ -322,7 +322,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0730;
|
||||
LastUpgradeCheck = 0710;
|
||||
LastUpgradeCheck = 0820;
|
||||
ORGANIZATIONNAME = smumryak;
|
||||
TargetAttributes = {
|
||||
AFF75A231C37279600F450AC = {
|
||||
@@ -330,7 +330,7 @@
|
||||
};
|
||||
B423AE191C0DF76A0004A2F1 = {
|
||||
CreatedOnToolsVersion = 7.1.1;
|
||||
LastSwiftMigration = 0800;
|
||||
LastSwiftMigration = 0820;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -463,6 +463,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -472,9 +473,11 @@
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
@@ -509,6 +512,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -518,9 +522,11 @@
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
@@ -538,6 +544,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
@@ -552,6 +559,7 @@
|
||||
BITCODE_GENERATION_MODE = marker;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
@@ -575,6 +583,7 @@
|
||||
BITCODE_GENERATION_MODE = bitcode;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0720"
|
||||
LastUpgradeVersion = "0820"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0720"
|
||||
LastUpgradeVersion = "0820"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
Reference in New Issue
Block a user