Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
Zip
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
YongYue
Zip
Commits
c898c506
Commit
c898c506
authored
Mar 17, 2016
by
Jake
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'marmelroy/master'
parents
e2615167
5b0f8066
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
34 additions
and
16 deletions
+34
-16
README.md
README.md
+1
-1
Zip.podspec
Zip.podspec
+1
-1
Zip.xcodeproj/project.pbxproj
Zip.xcodeproj/project.pbxproj
+8
-8
Zip/Info.plist
Zip/Info.plist
+2
-2
Zip/Zip.swift
Zip/Zip.swift
+3
-2
ZipTests/Info.plist
ZipTests/Info.plist
+2
-2
ZipTests/ZipTests.swift
ZipTests/ZipTests.swift
+17
-0
ZipTests/bb8.zip
ZipTests/bb8.zip
+0
-0
No files found.
README.md
View file @
c898c506
...
@@ -72,5 +72,5 @@ github "marmelroy/Zip"
...
@@ -72,5 +72,5 @@ github "marmelroy/Zip"
### Setting up with [CocoaPods](http://cocoapods.org/?q=Zip)
### Setting up with [CocoaPods](http://cocoapods.org/?q=Zip)
```
ruby
```
ruby
source
'https://github.com/CocoaPods/Specs.git'
source
'https://github.com/CocoaPods/Specs.git'
pod
'Zip'
,
'~> 0.
2
'
pod
'Zip'
,
'~> 0.
3
'
```
```
Zip.podspec
View file @
c898c506
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
Pod
::
Spec
.
new
do
|
s
|
Pod
::
Spec
.
new
do
|
s
|
s
.
name
=
"Zip"
s
.
name
=
"Zip"
s
.
version
=
"0.3.
2
"
s
.
version
=
"0.3.
4
"
s
.
summary
=
"Zip and unzip files in Swift."
s
.
summary
=
"Zip and unzip files in Swift."
# This description is used to generate tags and improve search results.
# This description is used to generate tags and improve search results.
...
...
Zip.xcodeproj/project.pbxproj
View file @
c898c506
...
@@ -556,10 +556,10 @@
...
@@ -556,10 +556,10 @@
buildSettings
=
{
buildSettings
=
{
CODE_SIGN_IDENTITY
=
"-"
;
CODE_SIGN_IDENTITY
=
"-"
;
COMBINE_HIDPI_IMAGES
=
YES
;
COMBINE_HIDPI_IMAGES
=
YES
;
CURRENT_PROJECT_VERSION
=
2
;
CURRENT_PROJECT_VERSION
=
4
;
DEFINES_MODULE
=
YES
;
DEFINES_MODULE
=
YES
;
DYLIB_COMPATIBILITY_VERSION
=
1
;
DYLIB_COMPATIBILITY_VERSION
=
1
;
DYLIB_CURRENT_VERSION
=
2
;
DYLIB_CURRENT_VERSION
=
4
;
DYLIB_INSTALL_NAME_BASE
=
"@rpath"
;
DYLIB_INSTALL_NAME_BASE
=
"@rpath"
;
FRAMEWORK_VERSION
=
A
;
FRAMEWORK_VERSION
=
A
;
INFOPLIST_FILE
=
Zip/Info.plist
;
INFOPLIST_FILE
=
Zip/Info.plist
;
...
@@ -579,10 +579,10 @@
...
@@ -579,10 +579,10 @@
buildSettings
=
{
buildSettings
=
{
CODE_SIGN_IDENTITY
=
"-"
;
CODE_SIGN_IDENTITY
=
"-"
;
COMBINE_HIDPI_IMAGES
=
YES
;
COMBINE_HIDPI_IMAGES
=
YES
;
CURRENT_PROJECT_VERSION
=
2
;
CURRENT_PROJECT_VERSION
=
4
;
DEFINES_MODULE
=
YES
;
DEFINES_MODULE
=
YES
;
DYLIB_COMPATIBILITY_VERSION
=
1
;
DYLIB_COMPATIBILITY_VERSION
=
1
;
DYLIB_CURRENT_VERSION
=
2
;
DYLIB_CURRENT_VERSION
=
4
;
DYLIB_INSTALL_NAME_BASE
=
"@rpath"
;
DYLIB_INSTALL_NAME_BASE
=
"@rpath"
;
FRAMEWORK_VERSION
=
A
;
FRAMEWORK_VERSION
=
A
;
INFOPLIST_FILE
=
Zip/Info.plist
;
INFOPLIST_FILE
=
Zip/Info.plist
;
...
@@ -644,7 +644,7 @@
...
@@ -644,7 +644,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH
=
YES
;
CLANG_WARN__DUPLICATE_METHOD_MATCH
=
YES
;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]"
=
"iPhone Developer"
;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]"
=
"iPhone Developer"
;
COPY_PHASE_STRIP
=
NO
;
COPY_PHASE_STRIP
=
NO
;
CURRENT_PROJECT_VERSION
=
2
;
CURRENT_PROJECT_VERSION
=
4
;
DEBUG_INFORMATION_FORMAT
=
dwarf
;
DEBUG_INFORMATION_FORMAT
=
dwarf
;
ENABLE_STRICT_OBJC_MSGSEND
=
YES
;
ENABLE_STRICT_OBJC_MSGSEND
=
YES
;
ENABLE_TESTABILITY
=
YES
;
ENABLE_TESTABILITY
=
YES
;
...
@@ -692,7 +692,7 @@
...
@@ -692,7 +692,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH
=
YES
;
CLANG_WARN__DUPLICATE_METHOD_MATCH
=
YES
;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]"
=
"iPhone Developer"
;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]"
=
"iPhone Developer"
;
COPY_PHASE_STRIP
=
NO
;
COPY_PHASE_STRIP
=
NO
;
CURRENT_PROJECT_VERSION
=
2
;
CURRENT_PROJECT_VERSION
=
4
;
DEBUG_INFORMATION_FORMAT
=
"dwarf-with-dsym"
;
DEBUG_INFORMATION_FORMAT
=
"dwarf-with-dsym"
;
ENABLE_NS_ASSERTIONS
=
NO
;
ENABLE_NS_ASSERTIONS
=
NO
;
ENABLE_STRICT_OBJC_MSGSEND
=
YES
;
ENABLE_STRICT_OBJC_MSGSEND
=
YES
;
...
@@ -721,7 +721,7 @@
...
@@ -721,7 +721,7 @@
CLANG_ENABLE_MODULES
=
YES
;
CLANG_ENABLE_MODULES
=
YES
;
DEFINES_MODULE
=
YES
;
DEFINES_MODULE
=
YES
;
DYLIB_COMPATIBILITY_VERSION
=
1
;
DYLIB_COMPATIBILITY_VERSION
=
1
;
DYLIB_CURRENT_VERSION
=
2
;
DYLIB_CURRENT_VERSION
=
4
;
DYLIB_INSTALL_NAME_BASE
=
"@rpath"
;
DYLIB_INSTALL_NAME_BASE
=
"@rpath"
;
INFOPLIST_FILE
=
Zip/Info.plist
;
INFOPLIST_FILE
=
Zip/Info.plist
;
INSTALL_PATH
=
"$(LOCAL_LIBRARY_DIR)/Frameworks"
;
INSTALL_PATH
=
"$(LOCAL_LIBRARY_DIR)/Frameworks"
;
...
@@ -743,7 +743,7 @@
...
@@ -743,7 +743,7 @@
CLANG_ENABLE_MODULES
=
YES
;
CLANG_ENABLE_MODULES
=
YES
;
DEFINES_MODULE
=
YES
;
DEFINES_MODULE
=
YES
;
DYLIB_COMPATIBILITY_VERSION
=
1
;
DYLIB_COMPATIBILITY_VERSION
=
1
;
DYLIB_CURRENT_VERSION
=
2
;
DYLIB_CURRENT_VERSION
=
4
;
DYLIB_INSTALL_NAME_BASE
=
"@rpath"
;
DYLIB_INSTALL_NAME_BASE
=
"@rpath"
;
INFOPLIST_FILE
=
Zip/Info.plist
;
INFOPLIST_FILE
=
Zip/Info.plist
;
INSTALL_PATH
=
"$(LOCAL_LIBRARY_DIR)/Frameworks"
;
INSTALL_PATH
=
"$(LOCAL_LIBRARY_DIR)/Frameworks"
;
...
...
Zip/Info.plist
View file @
c898c506
...
@@ -15,11 +15,11 @@
...
@@ -15,11 +15,11 @@
<key>
CFBundlePackageType
</key>
<key>
CFBundlePackageType
</key>
<string>
FMWK
</string>
<string>
FMWK
</string>
<key>
CFBundleShortVersionString
</key>
<key>
CFBundleShortVersionString
</key>
<string>
0.3.
2
</string>
<string>
0.3.
4
</string>
<key>
CFBundleSignature
</key>
<key>
CFBundleSignature
</key>
<string>
????
</string>
<string>
????
</string>
<key>
CFBundleVersion
</key>
<key>
CFBundleVersion
</key>
<string>
2
</string>
<string>
4
</string>
<key>
NSPrincipalClass
</key>
<key>
NSPrincipalClass
</key>
<string></string>
<string></string>
</dict>
</dict>
...
...
Zip/Zip.swift
View file @
c898c506
...
@@ -61,7 +61,7 @@ public class Zip {
...
@@ -61,7 +61,7 @@ public class Zip {
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
NSFileManager
.
defaultManager
()
// Check whether a zip file exists at path.
// Check whether a zip file exists at path.
guard
let
path
=
zipFilePath
.
path
,
let
destinationPath
=
destination
.
path
else
{
guard
let
path
=
zipFilePath
.
path
where
destination
.
path
!=
nil
else
{
throw
ZipError
.
FileNotFound
throw
ZipError
.
FileNotFound
}
}
if
fileManager
.
fileExistsAtPath
(
path
)
==
false
||
zipFilePath
.
pathExtension
!=
"zip"
{
if
fileManager
.
fileExistsAtPath
(
path
)
==
false
||
zipFilePath
.
pathExtension
!=
"zip"
{
...
@@ -134,7 +134,8 @@ public class Zip {
...
@@ -134,7 +134,8 @@ public class Zip {
try
fileManager
.
createDirectoryAtPath
(
fullPath
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
try
fileManager
.
createDirectoryAtPath
(
fullPath
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
}
}
else
{
else
{
try
fileManager
.
createDirectoryAtPath
(
destinationPath
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
let
parentDirectory
=
(
fullPath
as
NSString
)
.
stringByDeletingLastPathComponent
try
fileManager
.
createDirectoryAtPath
(
parentDirectory
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
}
}
}
catch
{}
}
catch
{}
if
fileManager
.
fileExistsAtPath
(
fullPath
)
&&
!
isDirectory
&&
!
overwrite
{
if
fileManager
.
fileExistsAtPath
(
fullPath
)
&&
!
isDirectory
&&
!
overwrite
{
...
...
ZipTests/Info.plist
View file @
c898c506
...
@@ -15,10 +15,10 @@
...
@@ -15,10 +15,10 @@
<key>
CFBundlePackageType
</key>
<key>
CFBundlePackageType
</key>
<string>
BNDL
</string>
<string>
BNDL
</string>
<key>
CFBundleShortVersionString
</key>
<key>
CFBundleShortVersionString
</key>
<string>
0.3.
2
</string>
<string>
0.3.
4
</string>
<key>
CFBundleSignature
</key>
<key>
CFBundleSignature
</key>
<string>
????
</string>
<string>
????
</string>
<key>
CFBundleVersion
</key>
<key>
CFBundleVersion
</key>
<string>
2
</string>
<string>
4
</string>
</dict>
</dict>
</plist>
</plist>
ZipTests/ZipTests.swift
View file @
c898c506
...
@@ -148,5 +148,22 @@ class ZipTests: XCTestCase {
...
@@ -148,5 +148,22 @@ class ZipTests: XCTestCase {
}
}
}
}
func
testQuickUnzipSubDir
()
{
do
{
let
bookURL
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"bb8"
,
withExtension
:
"zip"
)
!
let
unzipDestination
=
try
Zip
.
quickUnzipFile
(
bookURL
)
let
fileManager
=
NSFileManager
.
defaultManager
()
let
subDir
=
unzipDestination
.
URLByAppendingPathComponent
(
"subDir"
)
let
imageURL
=
subDir
.
URLByAppendingPathComponent
(
"r2W9yu9"
)
.
URLByAppendingPathExtension
(
"gif"
)
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
unzipDestination
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
subDir
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
imageURL
.
path
!
))
}
catch
{
XCTFail
()
}
}
}
}
ZipTests/bb8.zip
View file @
c898c506
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment