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
3051d09d
Commit
3051d09d
authored
Mar 16, 2016
by
Jake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unzipping files within sub directory
parent
e2615167
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
1 deletion
+19
-1
Zip/Zip.swift
Zip/Zip.swift
+2
-1
ZipTests/ZipTests.swift
ZipTests/ZipTests.swift
+17
-0
ZipTests/bb8.zip
ZipTests/bb8.zip
+0
-0
No files found.
Zip/Zip.swift
View file @
3051d09d
...
...
@@ -134,7 +134,8 @@ public class Zip {
try
fileManager
.
createDirectoryAtPath
(
fullPath
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
}
else
{
try
fileManager
.
createDirectoryAtPath
(
destinationPath
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
let
parentDirectory
=
(
fullPath
as
NSString
)
.
stringByDeletingLastPathComponent
try
fileManager
.
createDirectoryAtPath
(
parentDirectory
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
}
}
catch
{}
if
fileManager
.
fileExistsAtPath
(
fullPath
)
&&
!
isDirectory
&&
!
overwrite
{
...
...
ZipTests/ZipTests.swift
View file @
3051d09d
...
...
@@ -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 @
3051d09d
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