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
8167a471
Commit
8167a471
authored
Jan 26, 2018
by
Kristaps Grinbergs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #121
Documents directory doesn't exist for tvOS device.
parent
e0935dcb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
Zip/QuickZip.swift
Zip/QuickZip.swift
+17
-2
No files found.
Zip/QuickZip.swift
View file @
8167a471
...
...
@@ -10,6 +10,21 @@ import Foundation
extension
Zip
{
/**
Get search path directory. For tvOS Documents directory doesn't exist.
- returns: Search path directory
*/
fileprivate
class
func
searchPathDirectory
()
->
FileManager
.
SearchPathDirectory
{
var
searchPathDirectory
:
FileManager
.
SearchPathDirectory
=
.
documentDirectory
#if os(tvOS)
searchPathDirectory
=
.
cachesDirectory
#endif
return
searchPathDirectory
}
//MARK: Quick Unzip
/**
...
...
@@ -44,7 +59,7 @@ extension Zip {
let
fileName
=
path
.
lastPathComponent
let
directoryName
=
fileName
.
replacingOccurrences
(
of
:
".
\(
fileExtension
)
"
,
with
:
""
)
let
documentsUrl
=
fileManager
.
urls
(
for
:
.
documentDirectory
,
in
:
.
userDomainMask
)[
0
]
as
URL
let
documentsUrl
=
fileManager
.
urls
(
for
:
self
.
searchPathDirectory
()
,
in
:
.
userDomainMask
)[
0
]
as
URL
do
{
let
destinationUrl
=
documentsUrl
.
appendingPathComponent
(
directoryName
,
isDirectory
:
true
)
try
self
.
unzipFile
(
path
,
destination
:
destinationUrl
,
overwrite
:
true
,
password
:
nil
,
progress
:
progress
)
...
...
@@ -87,7 +102,7 @@ extension Zip {
*/
public
class
func
quickZipFiles
(
_
paths
:
[
URL
],
fileName
:
String
,
progress
:
((
_
progress
:
Double
)
->
())?)
throws
->
URL
{
let
fileManager
=
FileManager
.
default
let
documentsUrl
=
fileManager
.
urls
(
for
:
.
documentDirectory
,
in
:
.
userDomainMask
)[
0
]
as
URL
let
documentsUrl
=
fileManager
.
urls
(
for
:
self
.
searchPathDirectory
()
,
in
:
.
userDomainMask
)[
0
]
as
URL
let
destinationUrl
=
documentsUrl
.
appendingPathComponent
(
"
\(
fileName
)
.zip"
)
try
self
.
zipFiles
(
paths
:
paths
,
zipFilePath
:
destinationUrl
,
password
:
nil
,
progress
:
progress
)
return
destinationUrl
...
...
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