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
0ceb53ab
Commit
0ceb53ab
authored
Jul 28, 2016
by
Mostafa Berg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+Updated Unit tests to use Swift 2.3, all tests passing
parent
6e161445
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
19 deletions
+23
-19
ZipTests/ZipTests.swift
ZipTests/ZipTests.swift
+23
-19
No files found.
ZipTests/ZipTests.swift
View file @
0ceb53ab
...
@@ -128,7 +128,7 @@ class ZipTests: XCTestCase {
...
@@ -128,7 +128,7 @@ class ZipTests: XCTestCase {
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
progress
.
becomeCurrentWithPendingUnitCount
(
1
)
progress
.
becomeCurrentWithPendingUnitCount
(
1
)
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
,
password
:
nil
,
progress
:
nil
)
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
!
,
password
:
nil
,
progress
:
nil
)
progress
.
resignCurrent
()
progress
.
resignCurrent
()
XCTAssertTrue
(
progress
.
totalUnitCount
==
progress
.
completedUnitCount
)
XCTAssertTrue
(
progress
.
totalUnitCount
==
progress
.
completedUnitCount
)
...
@@ -158,15 +158,15 @@ class ZipTests: XCTestCase {
...
@@ -158,15 +158,15 @@ class ZipTests: XCTestCase {
let
imageURL1
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL1
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
folderURL
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
bundleURL
.
URLByAppendingPathComponent
(
"Directory"
)
let
folderURL
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
bundleURL
.
URLByAppendingPathComponent
(
"Directory"
)
let
targetImageURL1
=
folderURL
.
URLByAppendingPathComponent
(
"3crBXeO.gif"
)
let
targetImageURL1
=
folderURL
!
.
URLByAppendingPathComponent
(
"3crBXeO.gif"
)
let
targetImageURL2
=
folderURL
.
URLByAppendingPathComponent
(
"kYkLkPf.gif"
)
let
targetImageURL2
=
folderURL
!
.
URLByAppendingPathComponent
(
"kYkLkPf.gif"
)
if
fileManager
.
fileExistsAtPath
(
folderURL
.
path
!
)
{
if
fileManager
.
fileExistsAtPath
(
folderURL
!
.
path
!
)
{
try
fileManager
.
removeItemAtURL
(
folderURL
)
try
fileManager
.
removeItemAtURL
(
folderURL
!
)
}
}
try
fileManager
.
createDirectoryAtURL
(
folderURL
,
withIntermediateDirectories
:
false
,
attributes
:
nil
)
try
fileManager
.
createDirectoryAtURL
(
folderURL
!
,
withIntermediateDirectories
:
false
,
attributes
:
nil
)
try
fileManager
.
copyItemAtURL
(
imageURL1
,
toURL
:
targetImageURL1
)
try
fileManager
.
copyItemAtURL
(
imageURL1
,
toURL
:
targetImageURL1
!
)
try
fileManager
.
copyItemAtURL
(
imageURL2
,
toURL
:
targetImageURL2
)
try
fileManager
.
copyItemAtURL
(
imageURL2
,
toURL
:
targetImageURL2
!
)
let
destinationURL
=
try
Zip
.
quickZipFiles
([
folderURL
],
fileName
:
"directory"
)
let
destinationURL
=
try
Zip
.
quickZipFiles
([
folderURL
!
],
fileName
:
"directory"
)
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
destinationURL
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
destinationURL
.
path
!
))
}
}
catch
{
catch
{
...
@@ -181,11 +181,11 @@ class ZipTests: XCTestCase {
...
@@ -181,11 +181,11 @@ class ZipTests: XCTestCase {
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
,
password
:
nil
,
progress
:
{
(
progress
)
->
()
in
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
!
,
password
:
nil
,
progress
:
{
(
progress
)
->
()
in
print
(
progress
)
print
(
progress
)
})
})
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
NSFileManager
.
defaultManager
()
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
zipFilePath
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
(
zipFilePath
?
.
path
)
!
))
}
}
catch
{
catch
{
XCTFail
()
XCTFail
()
...
@@ -198,19 +198,23 @@ class ZipTests: XCTestCase {
...
@@ -198,19 +198,23 @@ class ZipTests: XCTestCase {
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
,
password
:
"password"
,
progress
:
{
(
progress
)
->
()
in
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
!
,
password
:
"password"
,
progress
:
{
(
progress
)
->
()
in
print
(
progress
)
print
(
progress
)
})
})
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
NSFileManager
.
defaultManager
()
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
zipFilePath
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
((
zipFilePath
?
.
path
)
!
))
guard
let
fileExtension
=
zipFilePath
.
pathExtension
,
let
fileName
=
zipFilePath
.
lastPathComponent
else
{
let
fileExtension
=
zipFilePath
!.
pathExtension
let
fileName
=
(
zipFilePath
?
.
lastPathComponent
)
!
guard
fileExtension
!=
nil
&&
fileName
.
characters
.
count
>
0
else
{
throw
ZipError
.
UnzipFail
throw
ZipError
.
UnzipFail
}
}
let
directoryName
=
fileName
.
stringByReplacingOccurrencesOfString
(
".
\(
fileExtension
)
"
,
withString
:
""
)
let
directoryName
=
fileName
.
stringByReplacingOccurrencesOfString
(
".
\(
fileExtension
)
"
,
withString
:
""
)
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
destinationUrl
=
documentsUrl
.
URLByAppendingPathComponent
(
directoryName
,
isDirectory
:
true
)
let
destinationUrl
=
documentsUrl
.
URLByAppendingPathComponent
(
directoryName
,
isDirectory
:
true
)
try
Zip
.
unzipFile
(
zipFilePath
,
destination
:
destinationUrl
,
overwrite
:
true
,
password
:
"password"
,
progress
:
nil
)
try
Zip
.
unzipFile
(
zipFilePath
!
,
destination
:
destinationUrl
!
,
overwrite
:
true
,
password
:
"password"
,
progress
:
nil
)
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
destinationUrl
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
destinationUrl
!
.
path
!
))
}
}
catch
{
catch
{
XCTFail
()
XCTFail
()
...
@@ -225,11 +229,11 @@ class ZipTests: XCTestCase {
...
@@ -225,11 +229,11 @@ class ZipTests: XCTestCase {
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
NSFileManager
.
defaultManager
()
let
subDir
=
unzipDestination
.
URLByAppendingPathComponent
(
"subDir"
)
let
subDir
=
unzipDestination
.
URLByAppendingPathComponent
(
"subDir"
)
let
imageURL
=
subDir
.
URLByAppendingPathComponent
(
"r2W9yu9"
)
.
URLByAppendingPathExtension
(
"gif"
)
let
imageURL
=
subDir
!.
URLByAppendingPathComponent
(
"r2W9yu9"
)
!
.
URLByAppendingPathExtension
(
"gif"
)
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
unzipDestination
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
unzipDestination
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
subDir
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
subDir
!
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
imageURL
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
imageURL
!
.
path
!
))
}
catch
{
}
catch
{
XCTFail
()
XCTFail
()
}
}
...
...
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