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
d85e52d1
Commit
d85e52d1
authored
Mar 16, 2016
by
Roy Marmelstein
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8 from gwjakewelton/fix-unzipping-sub-dir
Fix unzipping files within sub directory
parents
e2615167
021375c8
Changes
3
Hide 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 @
d85e52d1
...
@@ -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/ZipTests.swift
View file @
d85e52d1
...
@@ -147,6 +147,23 @@ class ZipTests: XCTestCase {
...
@@ -147,6 +147,23 @@ class ZipTests: XCTestCase {
XCTFail
()
XCTFail
()
}
}
}
}
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 @
d85e52d1
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