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
cd81881d
Commit
cd81881d
authored
Apr 29, 2016
by
Roy Marmelstein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a zip / unzip with password test
parent
977af1db
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
ZipTests/ZipTests.swift
ZipTests/ZipTests.swift
+26
-0
No files found.
ZipTests/ZipTests.swift
View file @
cd81881d
...
...
@@ -192,6 +192,32 @@ class ZipTests: XCTestCase {
}
}
func
testZipUnzipPassword
()
{
do
{
let
imageURL1
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
,
password
:
"password"
,
progress
:
{
(
progress
)
->
()
in
print
(
progress
)
})
let
fileManager
=
NSFileManager
.
defaultManager
()
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
zipFilePath
.
path
!
))
guard
let
fileExtension
=
zipFilePath
.
pathExtension
,
let
fileName
=
zipFilePath
.
lastPathComponent
else
{
throw
ZipError
.
UnzipFail
}
let
directoryName
=
fileName
.
stringByReplacingOccurrencesOfString
(
".
\(
fileExtension
)
"
,
withString
:
""
)
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
destinationUrl
=
documentsUrl
.
URLByAppendingPathComponent
(
directoryName
,
isDirectory
:
true
)
try
Zip
.
unzipFile
(
zipFilePath
,
destination
:
destinationUrl
,
overwrite
:
true
,
password
:
"password"
,
progress
:
nil
)
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
destinationUrl
.
path
!
))
}
catch
{
XCTFail
()
}
}
func
testQuickUnzipSubDir
()
{
do
{
let
bookURL
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"bb8"
,
withExtension
:
"zip"
)
!
...
...
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