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
88ba969d
Commit
88ba969d
authored
Aug 27, 2016
by
Roy Marmelstein
Committed by
GitHub
Aug 27, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #33 from mostafaberg/feature/Swift2.3
Feature/swift2.3
parents
4072a674
6db4fdaf
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
51 additions
and
34 deletions
+51
-34
.gitignore
.gitignore
+3
-0
Zip.xcodeproj/project.pbxproj
Zip.xcodeproj/project.pbxproj
+11
-1
Zip.xcodeproj/xcshareddata/xcschemes/Zip OSX.xcscheme
Zip.xcodeproj/xcshareddata/xcschemes/Zip OSX.xcscheme
+1
-1
Zip.xcodeproj/xcshareddata/xcschemes/Zip tvOS.xcscheme
Zip.xcodeproj/xcshareddata/xcschemes/Zip tvOS.xcscheme
+1
-1
Zip.xcodeproj/xcshareddata/xcschemes/Zip.xcscheme
Zip.xcodeproj/xcshareddata/xcschemes/Zip.xcscheme
+1
-1
Zip.xcodeproj/xcshareddata/xcschemes/ZipTests.xcscheme
Zip.xcodeproj/xcshareddata/xcschemes/ZipTests.xcscheme
+1
-1
Zip/QuickZip.swift
Zip/QuickZip.swift
+5
-5
Zip/Zip.swift
Zip/Zip.swift
+1
-1
Zip/ZipUtilities.swift
Zip/ZipUtilities.swift
+4
-4
ZipTests/ZipTests.swift
ZipTests/ZipTests.swift
+23
-19
No files found.
.gitignore
View file @
88ba969d
# MacOS
.DS_Store
# Xcode
# Xcode
#
#
build/
build/
...
...
Zip.xcodeproj/project.pbxproj
View file @
88ba969d
...
@@ -493,7 +493,7 @@
...
@@ -493,7 +493,7 @@
isa
=
PBXProject
;
isa
=
PBXProject
;
attributes
=
{
attributes
=
{
LastSwiftUpdateCheck
=
0720
;
LastSwiftUpdateCheck
=
0720
;
LastUpgradeCheck
=
0
72
0
;
LastUpgradeCheck
=
0
80
0
;
ORGANIZATIONNAME
=
"Roy Marmelstein"
;
ORGANIZATIONNAME
=
"Roy Marmelstein"
;
TargetAttributes
=
{
TargetAttributes
=
{
343F50FE1C8DAEEC0028C434
=
{
343F50FE1C8DAEEC0028C434
=
{
...
@@ -504,9 +504,11 @@
...
@@ -504,9 +504,11 @@
};
};
347E3A731C1DFFB500A11FD3
=
{
347E3A731C1DFFB500A11FD3
=
{
CreatedOnToolsVersion
=
7.2
;
CreatedOnToolsVersion
=
7.2
;
LastSwiftMigration
=
0800
;
};
};
347E3A7D1C1DFFB500A11FD3
=
{
347E3A7D1C1DFFB500A11FD3
=
{
CreatedOnToolsVersion
=
7.2
;
CreatedOnToolsVersion
=
7.2
;
LastSwiftMigration
=
0800
;
};
};
};
};
};
};
...
@@ -714,6 +716,7 @@
...
@@ -714,6 +716,7 @@
SKIP_INSTALL
=
YES
;
SKIP_INSTALL
=
YES
;
SUPPORTED_PLATFORMS
=
"appletvsimulator appletvos"
;
SUPPORTED_PLATFORMS
=
"appletvsimulator appletvos"
;
SWIFT_INCLUDE_PATHS
=
"${SRCROOT}/Zip/minizip/**"
;
SWIFT_INCLUDE_PATHS
=
"${SRCROOT}/Zip/minizip/**"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
TARGETED_DEVICE_FAMILY
=
3
;
TARGETED_DEVICE_FAMILY
=
3
;
TVOS_DEPLOYMENT_TARGET
=
9.0
;
TVOS_DEPLOYMENT_TARGET
=
9.0
;
};
};
...
@@ -762,6 +765,7 @@
...
@@ -762,6 +765,7 @@
SDKROOT
=
macosx
;
SDKROOT
=
macosx
;
SKIP_INSTALL
=
YES
;
SKIP_INSTALL
=
YES
;
SWIFT_INCLUDE_PATHS
=
"${SRCROOT}/Zip/minizip/**"
;
SWIFT_INCLUDE_PATHS
=
"${SRCROOT}/Zip/minizip/**"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
};
};
name
=
Release
;
name
=
Release
;
};
};
...
@@ -901,6 +905,7 @@
...
@@ -901,6 +905,7 @@
SKIP_INSTALL
=
YES
;
SKIP_INSTALL
=
YES
;
SWIFT_INCLUDE_PATHS
=
"${SRCROOT}/Zip/minizip/**"
;
SWIFT_INCLUDE_PATHS
=
"${SRCROOT}/Zip/minizip/**"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Onone"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Onone"
;
SWIFT_VERSION
=
2.3
;
};
};
name
=
Debug
;
name
=
Debug
;
};
};
...
@@ -922,6 +927,8 @@
...
@@ -922,6 +927,8 @@
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
SKIP_INSTALL
=
YES
;
SKIP_INSTALL
=
YES
;
SWIFT_INCLUDE_PATHS
=
"${SRCROOT}/Zip/minizip/**"
;
SWIFT_INCLUDE_PATHS
=
"${SRCROOT}/Zip/minizip/**"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
SWIFT_VERSION
=
2.3
;
};
};
name
=
Release
;
name
=
Release
;
};
};
...
@@ -932,6 +939,7 @@
...
@@ -932,6 +939,7 @@
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
;
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.roymarmelstein.ZipTests
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.roymarmelstein.ZipTests
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
SWIFT_VERSION
=
2.3
;
};
};
name
=
Debug
;
name
=
Debug
;
};
};
...
@@ -942,6 +950,8 @@
...
@@ -942,6 +950,8 @@
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
;
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.roymarmelstein.ZipTests
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.roymarmelstein.ZipTests
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
SWIFT_VERSION
=
2.3
;
};
};
name
=
Release
;
name
=
Release
;
};
};
...
...
Zip.xcodeproj/xcshareddata/xcschemes/Zip OSX.xcscheme
View file @
88ba969d
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
<Scheme
LastUpgradeVersion =
"0
72
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
version =
"1.3"
>
<BuildAction
<BuildAction
parallelizeBuildables =
"YES"
parallelizeBuildables =
"YES"
...
...
Zip.xcodeproj/xcshareddata/xcschemes/Zip tvOS.xcscheme
View file @
88ba969d
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
<Scheme
LastUpgradeVersion =
"0
73
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
version =
"1.3"
>
<BuildAction
<BuildAction
parallelizeBuildables =
"YES"
parallelizeBuildables =
"YES"
...
...
Zip.xcodeproj/xcshareddata/xcschemes/Zip.xcscheme
View file @
88ba969d
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
<Scheme
LastUpgradeVersion =
"0
72
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
version =
"1.3"
>
<BuildAction
<BuildAction
parallelizeBuildables =
"YES"
parallelizeBuildables =
"YES"
...
...
Zip.xcodeproj/xcshareddata/xcschemes/ZipTests.xcscheme
View file @
88ba969d
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
<Scheme
LastUpgradeVersion =
"0
72
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
version =
"1.3"
>
<BuildAction
<BuildAction
parallelizeBuildables =
"YES"
parallelizeBuildables =
"YES"
...
...
Zip/QuickZip.swift
View file @
88ba969d
...
@@ -45,8 +45,8 @@ extension Zip {
...
@@ -45,8 +45,8 @@ extension Zip {
let
directoryName
=
fileName
.
stringByReplacingOccurrencesOfString
(
".
\(
fileExtension
)
"
,
withString
:
""
)
let
directoryName
=
fileName
.
stringByReplacingOccurrencesOfString
(
".
\(
fileExtension
)
"
,
withString
:
""
)
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
destinationUrl
=
documentsUrl
.
URLByAppendingPathComponent
(
directoryName
,
isDirectory
:
true
)
let
destinationUrl
=
documentsUrl
.
URLByAppendingPathComponent
(
directoryName
,
isDirectory
:
true
)
try
self
.
unzipFile
(
path
,
destination
:
destinationUrl
,
overwrite
:
true
,
password
:
nil
,
progress
:
progress
)
try
self
.
unzipFile
(
path
,
destination
:
destinationUrl
!
,
overwrite
:
true
,
password
:
nil
,
progress
:
progress
)
return
destinationUrl
return
destinationUrl
!
}
}
//MARK: Quick Zip
//MARK: Quick Zip
...
@@ -84,8 +84,8 @@ extension Zip {
...
@@ -84,8 +84,8 @@ extension Zip {
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
NSFileManager
.
defaultManager
()
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
destinationUrl
=
documentsUrl
.
URLByAppendingPathComponent
(
"
\(
fileName
)
.zip"
)
let
destinationUrl
=
documentsUrl
.
URLByAppendingPathComponent
(
"
\(
fileName
)
.zip"
)
try
self
.
zipFiles
(
paths
,
zipFilePath
:
destinationUrl
,
password
:
nil
,
progress
:
progress
)
try
self
.
zipFiles
(
paths
,
zipFilePath
:
destinationUrl
!
,
password
:
nil
,
progress
:
progress
)
return
destinationUrl
return
destinationUrl
!
}
}
...
...
Zip/Zip.swift
View file @
88ba969d
...
@@ -139,7 +139,7 @@ public class Zip {
...
@@ -139,7 +139,7 @@ public class Zip {
if
pathString
.
rangeOfCharacterFromSet
(
NSCharacterSet
(
charactersInString
:
"/
\\
"
))
!=
nil
{
if
pathString
.
rangeOfCharacterFromSet
(
NSCharacterSet
(
charactersInString
:
"/
\\
"
))
!=
nil
{
pathString
=
pathString
.
stringByReplacingOccurrencesOfString
(
"
\\
"
,
withString
:
"/"
)
pathString
=
pathString
.
stringByReplacingOccurrencesOfString
(
"
\\
"
,
withString
:
"/"
)
}
}
guard
let
fullPath
=
destination
.
URLByAppendingPathComponent
(
pathString
)
.
path
else
{
guard
let
fullPath
=
destination
.
URLByAppendingPathComponent
(
pathString
)
!
.
path
else
{
throw
ZipError
.
UnzipFail
throw
ZipError
.
UnzipFail
}
}
let
creationDate
=
NSDate
()
let
creationDate
=
NSDate
()
...
...
Zip/ZipUtilities.swift
View file @
88ba969d
...
@@ -72,18 +72,18 @@ internal class ZipUtilities {
...
@@ -72,18 +72,18 @@ internal class ZipUtilities {
if
let
directoryPath
=
directory
.
path
,
let
enumerator
=
fileManager
.
enumeratorAtPath
(
directoryPath
)
{
if
let
directoryPath
=
directory
.
path
,
let
enumerator
=
fileManager
.
enumeratorAtPath
(
directoryPath
)
{
while
let
filePathComponent
=
enumerator
.
nextObject
()
as?
String
{
while
let
filePathComponent
=
enumerator
.
nextObject
()
as?
String
{
let
path
=
directory
.
URLByAppendingPathComponent
(
filePathComponent
)
let
path
=
directory
.
URLByAppendingPathComponent
(
filePathComponent
)
guard
let
filePath
=
path
.
path
,
let
directoryName
=
directory
.
lastPathComponent
else
{
guard
let
filePath
=
path
!
.
path
,
let
directoryName
=
directory
.
lastPathComponent
else
{
continue
continue
}
}
var
isDirectory
:
ObjCBool
=
false
var
isDirectory
:
ObjCBool
=
false
fileManager
.
fileExistsAtPath
(
filePath
,
isDirectory
:
&
isDirectory
)
fileManager
.
fileExistsAtPath
(
filePath
,
isDirectory
:
&
isDirectory
)
if
!
isDirectory
{
if
!
isDirectory
{
let
fileName
=
(
directoryName
as
NSString
)
.
stringByAppendingPathComponent
(
filePathComponent
)
let
fileName
=
(
directoryName
as
NSString
)
.
stringByAppendingPathComponent
(
filePathComponent
)
let
processedPath
=
ProcessedFilePath
(
filePathURL
:
path
,
fileName
:
fileName
)
let
processedPath
=
ProcessedFilePath
(
filePathURL
:
path
!
,
fileName
:
fileName
)
processedFilePaths
.
append
(
processedPath
)
processedFilePaths
.
append
(
processedPath
)
}
}
else
{
else
{
let
directoryContents
=
expandDirectoryFilePath
(
path
)
let
directoryContents
=
expandDirectoryFilePath
(
path
!
)
processedFilePaths
.
appendContentsOf
(
directoryContents
)
processedFilePaths
.
appendContentsOf
(
directoryContents
)
}
}
}
}
...
...
ZipTests/ZipTests.swift
View file @
88ba969d
...
@@ -128,7 +128,7 @@ class ZipTests: XCTestCase {
...
@@ -128,7 +128,7 @@ class ZipTests: XCTestCase {
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
progress
.
becomeCurrentWithPendingUnitCount
(
1
)
progress
.
becomeCurrentWithPendingUnitCount
(
1
)
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
,
password
:
nil
,
progress
:
nil
)
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
!
,
password
:
nil
,
progress
:
nil
)
progress
.
resignCurrent
()
progress
.
resignCurrent
()
XCTAssertTrue
(
progress
.
totalUnitCount
==
progress
.
completedUnitCount
)
XCTAssertTrue
(
progress
.
totalUnitCount
==
progress
.
completedUnitCount
)
...
@@ -158,15 +158,15 @@ class ZipTests: XCTestCase {
...
@@ -158,15 +158,15 @@ class ZipTests: XCTestCase {
let
imageURL1
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL1
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
folderURL
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
bundleURL
.
URLByAppendingPathComponent
(
"Directory"
)
let
folderURL
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
bundleURL
.
URLByAppendingPathComponent
(
"Directory"
)
let
targetImageURL1
=
folderURL
.
URLByAppendingPathComponent
(
"3crBXeO.gif"
)
let
targetImageURL1
=
folderURL
!
.
URLByAppendingPathComponent
(
"3crBXeO.gif"
)
let
targetImageURL2
=
folderURL
.
URLByAppendingPathComponent
(
"kYkLkPf.gif"
)
let
targetImageURL2
=
folderURL
!
.
URLByAppendingPathComponent
(
"kYkLkPf.gif"
)
if
fileManager
.
fileExistsAtPath
(
folderURL
.
path
!
)
{
if
fileManager
.
fileExistsAtPath
(
folderURL
!
.
path
!
)
{
try
fileManager
.
removeItemAtURL
(
folderURL
)
try
fileManager
.
removeItemAtURL
(
folderURL
!
)
}
}
try
fileManager
.
createDirectoryAtURL
(
folderURL
,
withIntermediateDirectories
:
false
,
attributes
:
nil
)
try
fileManager
.
createDirectoryAtURL
(
folderURL
!
,
withIntermediateDirectories
:
false
,
attributes
:
nil
)
try
fileManager
.
copyItemAtURL
(
imageURL1
,
toURL
:
targetImageURL1
)
try
fileManager
.
copyItemAtURL
(
imageURL1
,
toURL
:
targetImageURL1
!
)
try
fileManager
.
copyItemAtURL
(
imageURL2
,
toURL
:
targetImageURL2
)
try
fileManager
.
copyItemAtURL
(
imageURL2
,
toURL
:
targetImageURL2
!
)
let
destinationURL
=
try
Zip
.
quickZipFiles
([
folderURL
],
fileName
:
"directory"
)
let
destinationURL
=
try
Zip
.
quickZipFiles
([
folderURL
!
],
fileName
:
"directory"
)
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
destinationURL
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
destinationURL
.
path
!
))
}
}
catch
{
catch
{
...
@@ -181,11 +181,11 @@ class ZipTests: XCTestCase {
...
@@ -181,11 +181,11 @@ class ZipTests: XCTestCase {
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
,
password
:
nil
,
progress
:
{
(
progress
)
->
()
in
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
!
,
password
:
nil
,
progress
:
{
(
progress
)
->
()
in
print
(
progress
)
print
(
progress
)
})
})
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
NSFileManager
.
defaultManager
()
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
zipFilePath
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
(
zipFilePath
?
.
path
)
!
))
}
}
catch
{
catch
{
XCTFail
()
XCTFail
()
...
@@ -198,19 +198,23 @@ class ZipTests: XCTestCase {
...
@@ -198,19 +198,23 @@ class ZipTests: XCTestCase {
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
let
zipFilePath
=
documentsFolder
.
URLByAppendingPathComponent
(
"archive.zip"
)
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
,
password
:
"password"
,
progress
:
{
(
progress
)
->
()
in
try
Zip
.
zipFiles
([
imageURL1
,
imageURL2
],
zipFilePath
:
zipFilePath
!
,
password
:
"password"
,
progress
:
{
(
progress
)
->
()
in
print
(
progress
)
print
(
progress
)
})
})
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
NSFileManager
.
defaultManager
()
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
zipFilePath
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
((
zipFilePath
?
.
path
)
!
))
guard
let
fileExtension
=
zipFilePath
.
pathExtension
,
let
fileName
=
zipFilePath
.
lastPathComponent
else
{
let
fileExtension
=
zipFilePath
!.
pathExtension
let
fileName
=
(
zipFilePath
?
.
lastPathComponent
)
!
guard
fileExtension
!=
nil
&&
fileName
.
characters
.
count
>
0
else
{
throw
ZipError
.
UnzipFail
throw
ZipError
.
UnzipFail
}
}
let
directoryName
=
fileName
.
stringByReplacingOccurrencesOfString
(
".
\(
fileExtension
)
"
,
withString
:
""
)
let
directoryName
=
fileName
.
stringByReplacingOccurrencesOfString
(
".
\(
fileExtension
)
"
,
withString
:
""
)
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
destinationUrl
=
documentsUrl
.
URLByAppendingPathComponent
(
directoryName
,
isDirectory
:
true
)
let
destinationUrl
=
documentsUrl
.
URLByAppendingPathComponent
(
directoryName
,
isDirectory
:
true
)
try
Zip
.
unzipFile
(
zipFilePath
,
destination
:
destinationUrl
,
overwrite
:
true
,
password
:
"password"
,
progress
:
nil
)
try
Zip
.
unzipFile
(
zipFilePath
!
,
destination
:
destinationUrl
!
,
overwrite
:
true
,
password
:
"password"
,
progress
:
nil
)
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
destinationUrl
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
destinationUrl
!
.
path
!
))
}
}
catch
{
catch
{
XCTFail
()
XCTFail
()
...
@@ -225,11 +229,11 @@ class ZipTests: XCTestCase {
...
@@ -225,11 +229,11 @@ class ZipTests: XCTestCase {
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
NSFileManager
.
defaultManager
()
let
subDir
=
unzipDestination
.
URLByAppendingPathComponent
(
"subDir"
)
let
subDir
=
unzipDestination
.
URLByAppendingPathComponent
(
"subDir"
)
let
imageURL
=
subDir
.
URLByAppendingPathComponent
(
"r2W9yu9"
)
.
URLByAppendingPathExtension
(
"gif"
)
let
imageURL
=
subDir
!.
URLByAppendingPathComponent
(
"r2W9yu9"
)
!
.
URLByAppendingPathExtension
(
"gif"
)
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
unzipDestination
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
unzipDestination
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
subDir
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
subDir
!
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
imageURL
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
imageURL
!
.
path
!
))
}
catch
{
}
catch
{
XCTFail
()
XCTFail
()
}
}
...
...
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