Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f5a7b30dc | ||
|
|
bdbab4d3b3 | ||
|
|
fdb1726299 | ||
|
|
709006228c | ||
|
|
db0c62c481 | ||
|
|
d9ea638369 | ||
|
|
f18a98e551 | ||
|
|
557e869222 | ||
|
|
26630b36af | ||
|
|
581adbb98c | ||
|
|
d646bf93a2 | ||
|
|
b7598bc95f | ||
|
|
236fcb7d65 | ||
|
|
45009d71e7 |
@@ -1,12 +1,20 @@
|
||||
# SSZipArchive Changelog
|
||||
|
||||
### Version 0.2.1
|
||||
|
||||
[Released May 9, 2012](https://github.com/samsoffes/sskeychain/tree/0.2.1)
|
||||
|
||||
* Support for symbolic links — [@jparishy](http://github.com/jparishy)
|
||||
* Fix several warnings
|
||||
|
||||
### Version 0.2.0
|
||||
|
||||
[Released May 7, 2012](https://github.com/samsoffes/sskeychain/tree/0.2.0)
|
||||
|
||||
* Add unzipping delegate
|
||||
* Add unzipping delegate — [@uppfinnarn](http://github.com/uppfinnarn)
|
||||
* Fix unzipping with passwords
|
||||
* Fix modified at dates
|
||||
* Fix modified at dates — [@brantsears](http://github.com/brantsears)
|
||||
* Fix truncated files. Ignore the zip headers and unzip until there is no more file. — [@jparishy](http://github.com/jparishy)
|
||||
|
||||
### Version 0.1.2
|
||||
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2010-2011 Sam Soffes
|
||||
Copyright (c) 2010-2012 Sam Soffes
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#import "zlib.h"
|
||||
#import "zconf.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define CHUNK 16384
|
||||
|
||||
@interface SSZipArchive ()
|
||||
@@ -116,25 +118,26 @@
|
||||
// http://www.pkware.com/documents/casestudies/APPNOTE.TXT
|
||||
//
|
||||
// ...to deduce this method of detecting whether the file in the ZIP is a symbolic link.
|
||||
// If it is, it is listed as a directory but has an uncompressed data size greater than
|
||||
// zero (real directories have it equal to 0) and the included, uncompressed data is the
|
||||
// symbolic link path.
|
||||
// If it is, it is listed as a directory but has a data size greater than zero (real
|
||||
// directories have it equal to 0) and the included, uncompressed data is the symbolic link path.
|
||||
//
|
||||
// ZIP files did not originally include support for symbolic links so the specification
|
||||
// doesn't include anything in them that isn't part of a unix extension that isn't being used
|
||||
// by the archivers we're testing. Most of this is figured out through trial and error and
|
||||
// reading ZIP headers in hex editors. This seems to do the trick though.
|
||||
//
|
||||
|
||||
const uLong ZipDirectoryVersion = 10;
|
||||
const uLong ZipCompressionMethodStore = 0;
|
||||
|
||||
BOOL fileIsSymbolicLink = NO;
|
||||
|
||||
if((fileInfo.version_needed == ZipDirectoryVersion) && // Is it a directory?
|
||||
(fileInfo.compression_method == ZipCompressionMethodStore) && // Is it compressed?
|
||||
(fileInfo.compressed_size > 0)) // Is there any data there?
|
||||
if((fileInfo.compression_method == ZipCompressionMethodStore) && // Is it compressed?
|
||||
(S_ISDIR(fileInfo.external_fa)) && // Is it marked as a directory
|
||||
(fileInfo.compressed_size > 0)) // Is there any data?
|
||||
{
|
||||
fileIsSymbolicLink = YES;
|
||||
}
|
||||
|
||||
//NSLog(@"\"%s\" is symbolic link? %@", filename, fileIsSymbolicLink ? @"Yes." : @"No.");
|
||||
|
||||
// Check if it contains directory
|
||||
NSString *strPath = [NSString stringWithCString:filename encoding:NSUTF8StringEncoding];
|
||||
BOOL isDirectory = NO;
|
||||
|
||||
18
SSZipArchive.podspec
Normal file
18
SSZipArchive.podspec
Normal file
@@ -0,0 +1,18 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'SSZipArchive'
|
||||
s.version = '0.2.2'
|
||||
s.summary = 'Utility class for zipping and unzipping files on iOS and Mac.'
|
||||
s.homepage = 'https://github.com/samsoffes/ssziparchive'
|
||||
s.author = { 'Sam Soffes' => 'sam@samsoff.es' }
|
||||
s.source = { :git => 'https://github.com/samsoffes/ssziparchive.git', :tag => '0.2.2' }
|
||||
s.description = 'SSZipArchive is a simple utility class for zipping and unzipping files on iOS and Mac.'
|
||||
s.source_files = 'SSZipArchive.*', 'minizip/*.{h,c}'
|
||||
s.library = 'z'
|
||||
s.preserve_paths = ['Tests', '.gitignore']
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
|
||||
# Maintain the dir structure for headers
|
||||
def s.copy_header_mapping(from)
|
||||
from
|
||||
end
|
||||
end
|
||||
@@ -17,6 +17,7 @@
|
||||
B215FB6A143AD576003AC546 /* unzip.c in Sources */ = {isa = PBXBuildFile; fileRef = B215FB53143AD460003AC546 /* unzip.c */; };
|
||||
B215FB6B143AD576003AC546 /* zip.c in Sources */ = {isa = PBXBuildFile; fileRef = B215FB55143AD460003AC546 /* zip.c */; };
|
||||
B215FB6D143AD6FF003AC546 /* TestArchive.zip in Resources */ = {isa = PBXBuildFile; fileRef = B215FB6C143AD6FF003AC546 /* TestArchive.zip */; };
|
||||
B2283D5D155AD80F00F9395A /* Unicode.zip in Resources */ = {isa = PBXBuildFile; fileRef = B2283D5C155AD80F00F9395A /* Unicode.zip */; };
|
||||
B23FCC7F1558F1B70026375C /* TestPasswordArchive.zip in Resources */ = {isa = PBXBuildFile; fileRef = B23FCC7E1558F1B70026375C /* TestPasswordArchive.zip */; };
|
||||
C5AE4E64155A12760045F3ED /* IncorrectHeaders.zip in Resources */ = {isa = PBXBuildFile; fileRef = C5AE4E63155A12760045F3ED /* IncorrectHeaders.zip */; };
|
||||
C5AE4E6D155A8B010045F3ED /* SymbolicLink.zip in Resources */ = {isa = PBXBuildFile; fileRef = C5AE4E6C155A8B010045F3ED /* SymbolicLink.zip */; };
|
||||
@@ -41,6 +42,7 @@
|
||||
B215FB61143AD514003AC546 /* SSZipArchiveTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSZipArchiveTests.m; sourceTree = "<group>"; };
|
||||
B215FB64143AD527003AC546 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
|
||||
B215FB6C143AD6FF003AC546 /* TestArchive.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = TestArchive.zip; sourceTree = "<group>"; };
|
||||
B2283D5C155AD80F00F9395A /* Unicode.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = Unicode.zip; sourceTree = "<group>"; };
|
||||
B23FCC7E1558F1B70026375C /* TestPasswordArchive.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = TestPasswordArchive.zip; sourceTree = "<group>"; };
|
||||
C5AE4E63155A12760045F3ED /* IncorrectHeaders.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = IncorrectHeaders.zip; sourceTree = "<group>"; };
|
||||
C5AE4E6C155A8B010045F3ED /* SymbolicLink.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = SymbolicLink.zip; sourceTree = "<group>"; };
|
||||
@@ -118,6 +120,7 @@
|
||||
B215FB5E143AD505003AC546 /* SSZipArchiveTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B2283D5C155AD80F00F9395A /* Unicode.zip */,
|
||||
B215FB61143AD514003AC546 /* SSZipArchiveTests.m */,
|
||||
B215FB5F143AD514003AC546 /* SSZipArchiveTests-Info.plist */,
|
||||
C5AE4E63155A12760045F3ED /* IncorrectHeaders.zip */,
|
||||
@@ -184,6 +187,7 @@
|
||||
B23FCC7F1558F1B70026375C /* TestPasswordArchive.zip in Resources */,
|
||||
C5AE4E64155A12760045F3ED /* IncorrectHeaders.zip in Resources */,
|
||||
C5AE4E6D155A8B010045F3ED /* SymbolicLink.zip in Resources */,
|
||||
B2283D5D155AD80F00F9395A /* Unicode.zip in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
@implementation SSZipArchiveTests
|
||||
|
||||
- (void)setUp {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:[self _cachesPath:nil] error:nil];
|
||||
}
|
||||
//- (void)setUp {
|
||||
// [[NSFileManager defaultManager] removeItemAtPath:[self _cachesPath:nil] error:nil];
|
||||
//}
|
||||
|
||||
|
||||
- (void)testZipping {
|
||||
@@ -91,16 +91,35 @@
|
||||
|
||||
[SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:self];
|
||||
|
||||
NSString* testSymlink = [outputPath stringByAppendingPathComponent:@"SymbolicLink/GitHub.app"];
|
||||
NSString *testSymlinkFolder = [outputPath stringByAppendingPathComponent:@"SymbolicLink/GitHub.app"];
|
||||
NSString *testSymlinkFile = [outputPath stringByAppendingPathComponent:@"SymbolicLink/Icon.icns"];
|
||||
|
||||
NSError* error = nil;
|
||||
NSString* symlinkPath = [[NSFileManager defaultManager] destinationOfSymbolicLinkAtPath:testSymlink error:&error];
|
||||
NSError *error = nil;
|
||||
NSString *symlinkFolderPath = [[NSFileManager defaultManager] destinationOfSymbolicLinkAtPath:testSymlinkFolder error:&error];
|
||||
bool symbolicLinkToFolderPersists = ((symlinkFolderPath != nil) && [symlinkFolderPath isEqualToString:@"/Applications/GitHub.app"]) && (error == nil);
|
||||
|
||||
bool symbolicLinkPersists = ((symlinkPath != nil) && [symlinkPath isEqualToString:@"/Applications/GitHub.app"]) && (error == nil);
|
||||
error = nil;
|
||||
|
||||
STAssertTrue(symbolicLinkPersists, @"Symbolic links should persist from the original archive to the outputted files.");
|
||||
NSString *symlinkFilePath = [[NSFileManager defaultManager] destinationOfSymbolicLinkAtPath:testSymlinkFile error:&error];
|
||||
bool symbolicLinkToFilePersists = ((symlinkFilePath != nil) && [symlinkFilePath isEqualToString:@"/Applications/GitHub.app/Contents/Resources/AppIcon.icns"]) && (error == nil);
|
||||
|
||||
STAssertTrue(symbolicLinkToFilePersists && symbolicLinkToFolderPersists, @"Symbolic links should persist from the original archive to the outputted files.");
|
||||
}
|
||||
|
||||
- (void)testUnzippingWithUnicodeFilenameInside {
|
||||
|
||||
NSString* zipPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"Unicode" ofType:@"zip"];
|
||||
NSString* outputPath = [self _cachesPath:@"Unicode"];
|
||||
|
||||
[SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:self];
|
||||
|
||||
bool unicodeFilenameWasExtracted = [[NSFileManager defaultManager] fileExistsAtPath:[outputPath stringByAppendingPathComponent:@"Accént.txt"]];
|
||||
|
||||
bool unicodeFolderWasExtracted = [[NSFileManager defaultManager] fileExistsAtPath:[outputPath stringByAppendingPathComponent:@"Fólder/Nothing.txt"]];
|
||||
|
||||
STAssertTrue(unicodeFilenameWasExtracted, @"Files with filenames in unicode should be extracted properly.");
|
||||
STAssertTrue(unicodeFolderWasExtracted, @"Folders with names in unicode should be extracted propertly.");
|
||||
}
|
||||
|
||||
// Commented out to avoid checking in several gig file into the repository. Simply add a file named
|
||||
// `LargeArchive.zip` to the project and uncomment out these lines to test.
|
||||
|
||||
Binary file not shown.
BIN
Tests/Unicode.zip
Normal file
BIN
Tests/Unicode.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user