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
977af1db
Commit
977af1db
authored
Apr 29, 2016
by
Roy Marmelstein
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'jozsef-vesza-include-cbz'
parents
82686f86
d9bf08dc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
Zip/Zip.swift
Zip/Zip.swift
+14
-2
ZipTests/ZipTests.swift
ZipTests/ZipTests.swift
+11
-1
No files found.
Zip/Zip.swift
View file @
977af1db
...
...
@@ -66,7 +66,7 @@ public class Zip {
guard
let
path
=
zipFilePath
.
path
where
destination
.
path
!=
nil
else
{
throw
ZipError
.
FileNotFound
}
if
fileManager
.
fileExistsAtPath
(
path
)
==
false
||
zipFilePath
.
pathExtension
!=
"zip"
{
if
fileManager
.
fileExistsAtPath
(
path
)
==
false
||
fileExtensionIsInvalid
(
zipFilePath
.
pathExtension
)
{
throw
ZipError
.
FileNotFound
}
...
...
@@ -303,6 +303,18 @@ public class Zip {
progressTracker
.
completedUnitCount
=
Int64
(
totalSize
)
}
/**
Check if file extension is invalid.
- parameter fileExtension: A file extension.
- returns: false if the extension is "zip" or "cbz", otherwise true.
*/
internal
class
func
fileExtensionIsInvalid
(
fileExtension
:
String
?)
->
Bool
{
guard
let
fileExtension
=
fileExtension
else
{
return
true
}
return
!
[
"zip"
,
"cbz"
]
.
contains
(
fileExtension
)
}
}
\ No newline at end of file
ZipTests/ZipTests.swift
View file @
977af1db
...
...
@@ -209,5 +209,15 @@ class ZipTests: XCTestCase {
}
}
func
testFileExtensionIsInvalidForValidUrl
()
{
let
fileUrl
=
NSURL
(
string
:
"file.cbz"
)
let
result
=
Zip
.
fileExtensionIsInvalid
(
fileUrl
?
.
pathExtension
)
XCTAssertFalse
(
result
)
}
func
testFileExtensionIsInvalidForInvalidUrl
()
{
let
fileUrl
=
NSURL
(
string
:
"file.xyz"
)
let
result
=
Zip
.
fileExtensionIsInvalid
(
fileUrl
?
.
pathExtension
)
XCTAssertTrue
(
result
)
}
}
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