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
376f3efa
Commit
376f3efa
authored
Aug 09, 2016
by
Roy Marmelstein
Committed by
GitHub
Aug 09, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #36 from mostafaberg/feature/Swift3.0
Feature/swift3.0
parents
4072a674
cba7e3ec
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
218 additions
and
210 deletions
+218
-210
.gitignore
.gitignore
+2
-0
.travis.yml
.travis.yml
+2
-3
Zip.xcodeproj/project.pbxproj
Zip.xcodeproj/project.pbxproj
+11
-1
Zip.xcodeproj/project.xcworkspace/xcshareddata/Zip.xcscmblueprint
...eproj/project.xcworkspace/xcshareddata/Zip.xcscmblueprint
+1
-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
+21
-16
Zip/Zip.swift
Zip/Zip.swift
+75
-75
Zip/ZipUtilities.swift
Zip/ZipUtilities.swift
+20
-26
ZipTests/ZipTests.swift
ZipTests/ZipTests.swift
+76
-77
build.sh
build.sh
+6
-7
No files found.
.gitignore
View file @
376f3efa
# MacOS
.DS_Store
# Xcode
# Xcode
#
#
build/
build/
...
...
.travis.yml
View file @
376f3efa
osx_image
:
xcode
7.2
osx_image
:
xcode
8
language
:
objective-c
language
:
objective-c
env
:
env
:
global
:
global
:
...
@@ -6,9 +6,7 @@ env:
...
@@ -6,9 +6,7 @@ env:
-
LANG=en_US.UTF-8
-
LANG=en_US.UTF-8
before_install
:
before_install
:
-
brew update || brew update
-
brew update || brew update
-
brew outdated xctool || brew upgrade xctool
-
gem install cocoapods
-
gem install cocoapods
-
xcrun simctl list
install
:
echo "<3"
install
:
echo "<3"
env
:
env
:
-
MODE=framework
-
MODE=framework
...
@@ -19,3 +17,4 @@ script: ./build.sh $MODE
...
@@ -19,3 +17,4 @@ script: ./build.sh $MODE
branches
:
branches
:
only
:
only
:
-
master
-
master
-
swift3.0
Zip.xcodeproj/project.pbxproj
View file @
376f3efa
...
@@ -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
=
3.0
;
};
};
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
=
3.0
;
};
};
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
=
3.0
;
};
};
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
=
3.0
;
};
};
name
=
Release
;
name
=
Release
;
};
};
...
...
Zip.xcodeproj/project.xcworkspace/xcshareddata/Zip.xcscmblueprint
View file @
376f3efa
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "F3707899-72AE-49DA-9BDD-5CB0B64CF03A",
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "F3707899-72AE-49DA-9BDD-5CB0B64CF03A",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"8DA5B175D3FDB92A3B3CCBD4109A734F1316A3DD" : "Zip\/Zip\/minizip\/",
"8DA5B175D3FDB92A3B3CCBD4109A734F1316A3DD" : "Zip\/Zip\/minizip\/",
"3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4" : "Zip\/"
"3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4" : "Zip
-swift3
\/"
},
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "Zip",
"DVTSourceControlWorkspaceBlueprintNameKey" : "Zip",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
...
...
Zip.xcodeproj/xcshareddata/xcschemes/Zip OSX.xcscheme
View file @
376f3efa
<?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 @
376f3efa
<?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 @
376f3efa
<?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 @
376f3efa
<?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 @
376f3efa
...
@@ -21,7 +21,7 @@ extension Zip {
...
@@ -21,7 +21,7 @@ extension Zip {
- returns: NSURL of the destination folder.
- returns: NSURL of the destination folder.
*/
*/
public
class
func
quickUnzipFile
(
path
:
NSURL
)
throws
->
NS
URL
{
public
class
func
quickUnzipFile
(
_
path
:
URL
)
throws
->
URL
{
return
try
quickUnzipFile
(
path
,
progress
:
nil
)
return
try
quickUnzipFile
(
path
,
progress
:
nil
)
}
}
...
@@ -37,16 +37,21 @@ extension Zip {
...
@@ -37,16 +37,21 @@ extension Zip {
- returns: NSURL of the destination folder.
- returns: NSURL of the destination folder.
*/
*/
public
class
func
quickUnzipFile
(
path
:
NSURL
,
progress
:
((
progress
:
Double
)
->
())?)
throws
->
NSURL
{
public
class
func
quickUnzipFile
(
_
path
:
URL
,
progress
:
((
progress
:
Double
)
->
())?)
throws
->
URL
{
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
guard
let
fileExtension
=
path
.
pathExtension
,
let
fileName
=
path
.
lastPathComponent
else
{
throw
ZipError
.
UnzipFail
let
fileExtension
=
path
.
pathExtension
let
fileName
=
path
.
lastPathComponent
let
directoryName
=
fileName
.
replacingOccurrences
(
of
:
".
\(
fileExtension
)
"
,
with
:
""
)
let
documentsUrl
=
fileManager
.
urls
(
for
:
.
documentDirectory
,
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
)
return
destinationUrl
}
catch
{
throw
(
ZipError
.
unzipFail
)
}
}
let
directoryName
=
fileName
.
stringByReplacingOccurrencesOfString
(
".
\(
fileExtension
)
"
,
withString
:
""
)
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
let
destinationUrl
=
documentsUrl
.
URLByAppendingPathComponent
(
directoryName
,
isDirectory
:
true
)
try
self
.
unzipFile
(
path
,
destination
:
destinationUrl
,
overwrite
:
true
,
password
:
nil
,
progress
:
progress
)
return
destinationUrl
}
}
//MARK: Quick Zip
//MARK: Quick Zip
...
@@ -63,7 +68,7 @@ extension Zip {
...
@@ -63,7 +68,7 @@ extension Zip {
- returns: NSURL of the destination folder.
- returns: NSURL of the destination folder.
*/
*/
public
class
func
quickZipFiles
(
paths
:
[
NSURL
],
fileName
:
String
)
throws
->
NS
URL
{
public
class
func
quickZipFiles
(
_
paths
:
[
URL
],
fileName
:
String
)
throws
->
URL
{
return
try
quickZipFiles
(
paths
,
fileName
:
fileName
,
progress
:
nil
)
return
try
quickZipFiles
(
paths
,
fileName
:
fileName
,
progress
:
nil
)
}
}
...
@@ -80,13 +85,13 @@ extension Zip {
...
@@ -80,13 +85,13 @@ extension Zip {
- returns: NSURL of the destination folder.
- returns: NSURL of the destination folder.
*/
*/
public
class
func
quickZipFiles
(
paths
:
[
NSURL
],
fileName
:
String
,
progress
:
((
progress
:
Double
)
->
())?)
throws
->
NS
URL
{
public
class
func
quickZipFiles
(
_
paths
:
[
URL
],
fileName
:
String
,
progress
:
((
progress
:
Double
)
->
())?)
throws
->
URL
{
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NS
URL
let
documentsUrl
=
fileManager
.
urls
(
for
:
.
documentDirectory
,
in
:
.
userDomainMask
)[
0
]
as
URL
let
destinationUrl
=
documentsUrl
.
URLByA
ppendingPathComponent
(
"
\(
fileName
)
.zip"
)
let
destinationUrl
=
try!
documentsUrl
.
a
ppendingPathComponent
(
"
\(
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
}
}
}
}
\ No newline at end of file
Zip/Zip.swift
View file @
376f3efa
...
@@ -10,20 +10,20 @@ import Foundation
...
@@ -10,20 +10,20 @@ import Foundation
import
minizip
import
minizip
/// Zip error type
/// Zip error type
public
enum
ZipError
:
Error
Type
{
public
enum
ZipError
:
Error
{
/// File not found
/// File not found
case
F
ileNotFound
case
f
ileNotFound
/// Unzip fail
/// Unzip fail
case
U
nzipFail
case
u
nzipFail
/// Zip fail
/// Zip fail
case
Z
ipFail
case
z
ipFail
/// User readable description
/// User readable description
public
var
description
:
String
{
public
var
description
:
String
{
switch
self
{
switch
self
{
case
.
F
ileNotFound
:
return
NSLocalizedString
(
"File not found."
,
comment
:
""
)
case
.
f
ileNotFound
:
return
NSLocalizedString
(
"File not found."
,
comment
:
""
)
case
.
U
nzipFail
:
return
NSLocalizedString
(
"Failed to unzip file."
,
comment
:
""
)
case
.
u
nzipFail
:
return
NSLocalizedString
(
"Failed to unzip file."
,
comment
:
""
)
case
.
Z
ipFail
:
return
NSLocalizedString
(
"Failed to zip file."
,
comment
:
""
)
case
.
z
ipFail
:
return
NSLocalizedString
(
"Failed to zip file."
,
comment
:
""
)
}
}
}
}
}
}
...
@@ -62,37 +62,36 @@ public class Zip {
...
@@ -62,37 +62,36 @@ public class Zip {
- notes: Supports implicit progress composition
- notes: Supports implicit progress composition
*/
*/
public
class
func
unzipFile
(
zipFilePath
:
NSURL
,
destination
:
NS
URL
,
overwrite
:
Bool
,
password
:
String
?,
progress
:
((
progress
:
Double
)
->
())?)
throws
{
public
class
func
unzipFile
(
_
zipFilePath
:
URL
,
destination
:
URL
,
overwrite
:
Bool
,
password
:
String
?,
progress
:
((
progress
:
Double
)
->
())?)
throws
{
// File manager
// File manager
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
// Check whether a zip file exists at path.
// Check whether a zip file exists at path.
guard
let
path
=
zipFilePath
.
path
where
destination
.
path
!=
nil
else
{
let
path
=
zipFilePath
.
path
throw
ZipError
.
FileNotFound
}
if
fileManager
.
fileExists
(
atPath
:
path
)
==
false
||
fileExtensionIsInvalid
(
zipFilePath
.
pathExtension
)
{
if
fileManager
.
fileExistsAtPath
(
path
)
==
false
||
fileExtensionIsInvalid
(
zipFilePath
.
pathExtension
)
{
throw
ZipError
.
fileNotFound
throw
ZipError
.
FileNotFound
}
}
// Unzip set up
// Unzip set up
var
ret
:
Int32
=
0
var
ret
:
Int32
=
0
var
crc_ret
:
Int32
=
0
var
crc_ret
:
Int32
=
0
let
bufferSize
:
UInt32
=
4096
let
bufferSize
:
UInt32
=
4096
var
buffer
=
Array
<
CUnsignedChar
>
(
count
:
Int
(
bufferSize
),
repeatedValue
:
0
)
var
buffer
=
Array
<
CUnsignedChar
>
(
repeating
:
0
,
count
:
Int
(
bufferSize
)
)
// Progress handler set up
// Progress handler set up
var
totalSize
:
Double
=
0.0
var
totalSize
:
Double
=
0.0
var
currentPosition
:
Double
=
0.0
var
currentPosition
:
Double
=
0.0
let
fileAttributes
=
try
fileManager
.
attributesOfItem
AtPath
(
path
)
let
fileAttributes
=
try
fileManager
.
attributesOfItem
(
atPath
:
path
)
if
let
attributeFileSize
=
fileAttributes
[
NSFileS
ize
]
as?
Double
{
if
let
attributeFileSize
=
fileAttributes
[
FileAttributeKey
.
s
ize
]
as?
Double
{
totalSize
+=
attributeFileSize
totalSize
+=
attributeFileSize
}
}
let
progressTracker
=
NS
Progress
(
totalUnitCount
:
Int64
(
totalSize
))
let
progressTracker
=
Progress
(
totalUnitCount
:
Int64
(
totalSize
))
progressTracker
.
c
ancellable
=
false
progressTracker
.
isC
ancellable
=
false
progressTracker
.
p
ausable
=
false
progressTracker
.
isP
ausable
=
false
progressTracker
.
kind
=
NSProgressKindF
ile
progressTracker
.
kind
=
ProgressKind
.
f
ile
// Begin unzipping
// Begin unzipping
let
zip
=
unzOpen64
(
path
)
let
zip
=
unzOpen64
(
path
)
...
@@ -100,64 +99,67 @@ public class Zip {
...
@@ -100,64 +99,67 @@ public class Zip {
unzClose
(
zip
)
unzClose
(
zip
)
}
}
if
unzGoToFirstFile
(
zip
)
!=
UNZ_OK
{
if
unzGoToFirstFile
(
zip
)
!=
UNZ_OK
{
throw
ZipError
.
U
nzipFail
throw
ZipError
.
u
nzipFail
}
}
repeat
{
repeat
{
if
let
cPassword
=
password
?
.
cString
UsingEncoding
(
NSASCIIStringEncoding
)
{
if
let
cPassword
=
password
?
.
cString
(
using
:
String
.
Encoding
.
ascii
)
{
ret
=
unzOpenCurrentFilePassword
(
zip
,
cPassword
)
ret
=
unzOpenCurrentFilePassword
(
zip
,
cPassword
)
}
}
else
{
else
{
ret
=
unzOpenCurrentFile
(
zip
);
ret
=
unzOpenCurrentFile
(
zip
);
}
}
if
ret
!=
UNZ_OK
{
if
ret
!=
UNZ_OK
{
throw
ZipError
.
U
nzipFail
throw
ZipError
.
u
nzipFail
}
}
var
fileInfo
=
unz_file_info64
()
var
fileInfo
=
unz_file_info64
()
memset
(
&
fileInfo
,
0
,
sizeof
(
unz_file_info
))
memset
(
&
fileInfo
,
0
,
sizeof
(
unz_file_info
.
self
))
ret
=
unzGetCurrentFileInfo64
(
zip
,
&
fileInfo
,
nil
,
0
,
nil
,
0
,
nil
,
0
)
ret
=
unzGetCurrentFileInfo64
(
zip
,
&
fileInfo
,
nil
,
0
,
nil
,
0
,
nil
,
0
)
if
ret
!=
UNZ_OK
{
if
ret
!=
UNZ_OK
{
unzCloseCurrentFile
(
zip
)
unzCloseCurrentFile
(
zip
)
throw
ZipError
.
U
nzipFail
throw
ZipError
.
u
nzipFail
}
}
currentPosition
+=
Double
(
fileInfo
.
compressed_size
)
currentPosition
+=
Double
(
fileInfo
.
compressed_size
)
let
fileNameSize
=
Int
(
fileInfo
.
size_filename
)
+
1
let
fileNameSize
=
Int
(
fileInfo
.
size_filename
)
+
1
let
fileName
=
UnsafeMutablePointer
<
CChar
>.
alloc
(
fileNameSize
)
//let fileName = UnsafeMutablePointer<CChar>(allocatingCapacity: fileNameSize)
if
fileName
==
nil
{
let
fileName
=
UnsafeMutablePointer
<
CChar
>.
allocate
(
capacity
:
fileNameSize
)
throw
ZipError
.
UnzipFail
}
unzGetCurrentFileInfo64
(
zip
,
&
fileInfo
,
fileName
,
UInt
(
fileNameSize
),
nil
,
0
,
nil
,
0
)
unzGetCurrentFileInfo64
(
zip
,
&
fileInfo
,
fileName
,
UInt
(
fileNameSize
),
nil
,
0
,
nil
,
0
)
fileName
[
Int
(
fileInfo
.
size_filename
)]
=
0
fileName
[
Int
(
fileInfo
.
size_filename
)]
=
0
guard
var
pathString
=
String
(
CString
:
fileName
,
encoding
:
NSUTF8StringEncoding
)
else
{
var
pathString
=
String
(
cString
:
fileName
)
throw
ZipError
.
UnzipFail
guard
pathString
.
characters
.
count
>
0
else
{
throw
ZipError
.
unzipFail
}
}
var
isDirectory
=
false
var
isDirectory
=
false
let
fileInfoSizeFileName
=
Int
(
fileInfo
.
size_filename
-
1
)
let
fileInfoSizeFileName
=
Int
(
fileInfo
.
size_filename
-
1
)
if
(
fileName
[
fileInfoSizeFileName
]
==
"/"
.
cString
UsingEncoding
(
NSUTF8StringEncoding
)?
.
first
||
fileName
[
fileInfoSizeFileName
]
==
"
\\
"
.
cStringUsingEncoding
(
NSUTF8StringEncoding
)?
.
first
)
{
if
(
fileName
[
fileInfoSizeFileName
]
==
"/"
.
cString
(
using
:
String
.
Encoding
.
utf8
)?
.
first
||
fileName
[
fileInfoSizeFileName
]
==
"
\\
"
.
cString
(
using
:
String
.
Encoding
.
utf8
)?
.
first
)
{
isDirectory
=
true
;
isDirectory
=
true
;
}
}
free
(
fileName
)
free
(
fileName
)
if
pathString
.
rangeOfCharacterFromSet
(
NSCharacterSet
(
charactersInString
:
"/
\\
"
))
!=
nil
{
if
pathString
.
rangeOfCharacter
(
from
:
CharacterSet
(
charactersIn
:
"/
\\
"
))
!=
nil
{
pathString
=
pathString
.
stringByReplacingOccurrencesOfString
(
"
\\
"
,
withString
:
"/"
)
pathString
=
pathString
.
replacingOccurrences
(
of
:
"
\\
"
,
with
:
"/"
)
}
guard
let
fullPath
=
destination
.
URLByAppendingPathComponent
(
pathString
)
.
path
else
{
throw
ZipError
.
UnzipFail
}
}
let
creationDate
=
NSDate
()
let
directoryAttributes
=
[
NSFileCreationDate
:
creationDate
,
NSFileModificationDate
:
creationDate
]
let
fullPath
=
destination
.
appendingPathComponent
(
pathString
)
.
path
let
creationDate
=
Date
()
let
directoryAttributes
=
[
FileAttributeKey
.
creationDate
.
rawValue
:
creationDate
,
FileAttributeKey
.
modificationDate
.
rawValue
:
creationDate
]
do
{
do
{
if
isDirectory
{
if
isDirectory
{
try
fileManager
.
createDirectory
AtPath
(
fullPath
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
try
fileManager
.
createDirectory
(
atPath
:
fullPath
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
}
}
else
{
else
{
let
parentDirectory
=
(
fullPath
as
NSString
)
.
stringByD
eletingLastPathComponent
let
parentDirectory
=
(
fullPath
as
NSString
)
.
d
eletingLastPathComponent
try
fileManager
.
createDirectory
AtPath
(
parentDirectory
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
try
fileManager
.
createDirectory
(
atPath
:
parentDirectory
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
}
}
}
catch
{}
}
catch
{}
if
fileManager
.
fileExists
AtPath
(
fullPath
)
&&
!
isDirectory
&&
!
overwrite
{
if
fileManager
.
fileExists
(
atPath
:
fullPath
)
&&
!
isDirectory
&&
!
overwrite
{
unzCloseCurrentFile
(
zip
)
unzCloseCurrentFile
(
zip
)
ret
=
unzGoToNextFile
(
zip
)
ret
=
unzGoToNextFile
(
zip
)
}
}
var
filePointer
:
UnsafeMutablePointer
<
FILE
>
var
filePointer
:
UnsafeMutablePointer
<
FILE
>
?
filePointer
=
fopen
(
fullPath
,
"wb"
)
filePointer
=
fopen
(
fullPath
,
"wb"
)
while
filePointer
!=
nil
{
while
filePointer
!=
nil
{
let
readBytes
=
unzReadCurrentFile
(
zip
,
&
buffer
,
bufferSize
)
let
readBytes
=
unzReadCurrentFile
(
zip
,
&
buffer
,
bufferSize
)
...
@@ -171,7 +173,7 @@ public class Zip {
...
@@ -171,7 +173,7 @@ public class Zip {
fclose
(
filePointer
)
fclose
(
filePointer
)
crc_ret
=
unzCloseCurrentFile
(
zip
)
crc_ret
=
unzCloseCurrentFile
(
zip
)
if
crc_ret
==
UNZ_CRCERROR
{
if
crc_ret
==
UNZ_CRCERROR
{
throw
ZipError
.
U
nzipFail
throw
ZipError
.
u
nzipFail
}
}
ret
=
unzGoToNextFile
(
zip
)
ret
=
unzGoToNextFile
(
zip
)
...
@@ -207,15 +209,13 @@ public class Zip {
...
@@ -207,15 +209,13 @@ public class Zip {
- notes: Supports implicit progress composition
- notes: Supports implicit progress composition
*/
*/
public
class
func
zipFiles
(
paths
:
[
NSURL
],
zipFilePath
:
NS
URL
,
password
:
String
?,
progress
:
((
progress
:
Double
)
->
())?)
throws
{
public
class
func
zipFiles
(
_
paths
:
[
URL
],
zipFilePath
:
URL
,
password
:
String
?,
progress
:
((
progress
:
Double
)
->
())?)
throws
{
// File manager
// File manager
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
// Check whether a zip file exists at path.
// Check whether a zip file exists at path.
guard
let
destinationPath
=
zipFilePath
.
path
else
{
let
destinationPath
=
zipFilePath
.
path
throw
ZipError
.
FileNotFound
}
// Process zip paths
// Process zip paths
let
processedPaths
=
ZipUtilities
()
.
processZipPaths
(
paths
)
let
processedPaths
=
ZipUtilities
()
.
processZipPaths
(
paths
)
...
@@ -230,8 +230,8 @@ public class Zip {
...
@@ -230,8 +230,8 @@ public class Zip {
for
path
in
processedPaths
{
for
path
in
processedPaths
{
do
{
do
{
let
filePath
=
path
.
filePath
()
let
filePath
=
path
.
filePath
()
let
fileAttributes
=
try
fileManager
.
attributesOfItem
AtPath
(
filePath
)
let
fileAttributes
=
try
fileManager
.
attributesOfItem
(
atPath
:
filePath
)
let
fileSize
=
fileAttributes
[
NSFileS
ize
]
as?
Double
let
fileSize
=
fileAttributes
[
FileAttributeKey
.
s
ize
]
as?
Double
if
let
fileSize
=
fileSize
{
if
let
fileSize
=
fileSize
{
totalSize
+=
fileSize
totalSize
+=
fileSize
}
}
...
@@ -239,36 +239,36 @@ public class Zip {
...
@@ -239,36 +239,36 @@ public class Zip {
catch
{}
catch
{}
}
}
let
progressTracker
=
NS
Progress
(
totalUnitCount
:
Int64
(
totalSize
))
let
progressTracker
=
Progress
(
totalUnitCount
:
Int64
(
totalSize
))
progressTracker
.
c
ancellable
=
false
progressTracker
.
isC
ancellable
=
false
progressTracker
.
p
ausable
=
false
progressTracker
.
isP
ausable
=
false
progressTracker
.
kind
=
NSProgressKindF
ile
progressTracker
.
kind
=
ProgressKind
.
f
ile
// Begin Zipping
// Begin Zipping
let
zip
=
zipOpen
(
destinationPath
,
APPEND_STATUS_CREATE
)
let
zip
=
zipOpen
(
destinationPath
,
APPEND_STATUS_CREATE
)
for
path
in
processedPaths
{
for
path
in
processedPaths
{
let
filePath
=
path
.
filePath
()
let
filePath
=
path
.
filePath
()
var
isDirectory
:
ObjCBool
=
false
var
isDirectory
:
ObjCBool
=
false
fileManager
.
fileExists
AtPath
(
filePath
,
isDirectory
:
&
isDirectory
)
fileManager
.
fileExists
(
atPath
:
filePath
,
isDirectory
:
&
isDirectory
)
if
!
isDirectory
{
if
!
isDirectory
.
boolValue
{
let
input
=
fopen
(
filePath
,
"r"
)
let
input
=
fopen
(
filePath
,
"r"
)
if
input
==
nil
{
if
input
==
nil
{
throw
ZipError
.
Z
ipFail
throw
ZipError
.
z
ipFail
}
}
let
fileName
=
path
.
fileName
let
fileName
=
path
.
fileName
var
zipInfo
:
zip_fileinfo
=
zip_fileinfo
(
tmz_date
:
tm_zip
(
tm_sec
:
0
,
tm_min
:
0
,
tm_hour
:
0
,
tm_mday
:
0
,
tm_mon
:
0
,
tm_year
:
0
),
dosDate
:
0
,
internal_fa
:
0
,
external_fa
:
0
)
var
zipInfo
:
zip_fileinfo
=
zip_fileinfo
(
tmz_date
:
tm_zip
(
tm_sec
:
0
,
tm_min
:
0
,
tm_hour
:
0
,
tm_mday
:
0
,
tm_mon
:
0
,
tm_year
:
0
),
dosDate
:
0
,
internal_fa
:
0
,
external_fa
:
0
)
do
{
do
{
let
fileAttributes
=
try
fileManager
.
attributesOfItem
AtPath
(
filePath
)
let
fileAttributes
=
try
fileManager
.
attributesOfItem
(
atPath
:
filePath
)
if
let
fileDate
=
fileAttributes
[
NSFileModificationDate
]
as?
NS
Date
{
if
let
fileDate
=
fileAttributes
[
FileAttributeKey
.
modificationDate
]
as?
Date
{
let
components
=
NSCalendar
.
currentCalendar
()
.
components
([
.
Year
,
.
Month
,
.
Day
,
.
Hour
,
.
Minute
,
.
Second
],
fromDate
:
fileDate
)
let
components
=
Calendar
.
current
.
dateComponents
([
.
year
,
.
month
,
.
day
,
.
hour
,
.
minute
,
.
second
],
from
:
fileDate
)
zipInfo
.
tmz_date
.
tm_sec
=
UInt32
(
components
.
second
)
zipInfo
.
tmz_date
.
tm_sec
=
UInt32
(
components
.
second
!
)
zipInfo
.
tmz_date
.
tm_min
=
UInt32
(
components
.
minute
)
zipInfo
.
tmz_date
.
tm_min
=
UInt32
(
components
.
minute
!
)
zipInfo
.
tmz_date
.
tm_hour
=
UInt32
(
components
.
hour
)
zipInfo
.
tmz_date
.
tm_hour
=
UInt32
(
components
.
hour
!
)
zipInfo
.
tmz_date
.
tm_mday
=
UInt32
(
components
.
day
)
zipInfo
.
tmz_date
.
tm_mday
=
UInt32
(
components
.
day
!
)
zipInfo
.
tmz_date
.
tm_mon
=
UInt32
(
components
.
month
)
-
1
zipInfo
.
tmz_date
.
tm_mon
=
UInt32
(
components
.
month
!
)
-
1
zipInfo
.
tmz_date
.
tm_year
=
UInt32
(
components
.
year
)
zipInfo
.
tmz_date
.
tm_year
=
UInt32
(
components
.
year
!
)
}
}
if
let
fileSize
=
fileAttributes
[
NSFileS
ize
]
as?
Double
{
if
let
fileSize
=
fileAttributes
[
FileAttributeKey
.
s
ize
]
as?
Double
{
currentPosition
+=
fileSize
currentPosition
+=
fileSize
}
}
}
}
...
@@ -281,7 +281,7 @@ public class Zip {
...
@@ -281,7 +281,7 @@ public class Zip {
zipOpenNewFileInZip3
(
zip
,
fileName
,
&
zipInfo
,
nil
,
0
,
nil
,
0
,
nil
,
Z_DEFLATED
,
Z_DEFAULT_COMPRESSION
,
0
,
-
MAX_WBITS
,
DEF_MEM_LEVEL
,
Z_DEFAULT_STRATEGY
,
nil
,
0
)
zipOpenNewFileInZip3
(
zip
,
fileName
,
&
zipInfo
,
nil
,
0
,
nil
,
0
,
nil
,
Z_DEFLATED
,
Z_DEFAULT_COMPRESSION
,
0
,
-
MAX_WBITS
,
DEF_MEM_LEVEL
,
Z_DEFAULT_STRATEGY
,
nil
,
0
)
}
}
else
{
else
{
throw
ZipError
.
Z
ipFail
throw
ZipError
.
z
ipFail
}
}
var
length
:
Int
=
0
var
length
:
Int
=
0
while
(
feof
(
input
)
==
0
)
{
while
(
feof
(
input
)
==
0
)
{
...
@@ -318,7 +318,7 @@ public class Zip {
...
@@ -318,7 +318,7 @@ public class Zip {
- returns: false if the extension is a valid file extension, otherwise true.
- returns: false if the extension is a valid file extension, otherwise true.
*/
*/
internal
class
func
fileExtensionIsInvalid
(
fileExtension
:
String
?)
->
Bool
{
internal
class
func
fileExtensionIsInvalid
(
_
fileExtension
:
String
?)
->
Bool
{
guard
let
fileExtension
=
fileExtension
else
{
return
true
}
guard
let
fileExtension
=
fileExtension
else
{
return
true
}
...
@@ -330,7 +330,7 @@ public class Zip {
...
@@ -330,7 +330,7 @@ public class Zip {
- parameter fileExtension: A file extension.
- parameter fileExtension: A file extension.
*/
*/
public
class
func
addCustomFileExtension
(
fileExtension
:
String
)
{
public
class
func
addCustomFileExtension
(
_
fileExtension
:
String
)
{
customFileExtensions
.
insert
(
fileExtension
)
customFileExtensions
.
insert
(
fileExtension
)
}
}
...
@@ -339,7 +339,7 @@ public class Zip {
...
@@ -339,7 +339,7 @@ public class Zip {
- parameter fileExtension: A file extension.
- parameter fileExtension: A file extension.
*/
*/
public
class
func
removeCustomFileExtension
(
fileExtension
:
String
)
{
public
class
func
removeCustomFileExtension
(
_
fileExtension
:
String
)
{
customFileExtensions
.
remove
(
fileExtension
)
customFileExtensions
.
remove
(
fileExtension
)
}
}
...
@@ -350,7 +350,7 @@ public class Zip {
...
@@ -350,7 +350,7 @@ public class Zip {
- returns: true if the extension valid, otherwise false.
- returns: true if the extension valid, otherwise false.
*/
*/
public
class
func
isValidFileExtension
(
fileExtension
:
String
)
->
Bool
{
public
class
func
isValidFileExtension
(
_
fileExtension
:
String
)
->
Bool
{
let
validFileExtensions
:
Set
<
String
>
=
customFileExtensions
.
union
([
"zip"
,
"cbz"
])
let
validFileExtensions
:
Set
<
String
>
=
customFileExtensions
.
union
([
"zip"
,
"cbz"
])
...
...
Zip/ZipUtilities.swift
View file @
376f3efa
...
@@ -11,22 +11,17 @@ import Foundation
...
@@ -11,22 +11,17 @@ import Foundation
internal
class
ZipUtilities
{
internal
class
ZipUtilities
{
// File manager
// File manager
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
/**
/**
* ProcessedFilePath struct
* ProcessedFilePath struct
*/
*/
internal
struct
ProcessedFilePath
{
internal
struct
ProcessedFilePath
{
let
filePathURL
:
NS
URL
let
filePathURL
:
URL
let
fileName
:
String
?
let
fileName
:
String
?
func
filePath
()
->
String
{
func
filePath
()
->
String
{
if
let
filePath
=
filePathURL
.
path
{
return
filePathURL
.
path
return
filePath
}
else
{
return
String
()
}
}
}
}
}
...
@@ -39,21 +34,19 @@ internal class ZipUtilities {
...
@@ -39,21 +34,19 @@ internal class ZipUtilities {
- returns: Array of ProcessedFilePath structs.
- returns: Array of ProcessedFilePath structs.
*/
*/
internal
func
processZipPaths
(
paths
:
[
NS
URL
])
->
[
ProcessedFilePath
]{
internal
func
processZipPaths
(
_
paths
:
[
URL
])
->
[
ProcessedFilePath
]{
var
processedFilePaths
=
[
ProcessedFilePath
]()
var
processedFilePaths
=
[
ProcessedFilePath
]()
for
path
in
paths
{
for
path
in
paths
{
guard
let
filePath
=
path
.
path
else
{
let
filePath
=
path
.
path
continue
}
var
isDirectory
:
ObjCBool
=
false
var
isDirectory
:
ObjCBool
=
false
fileManager
.
fileExists
AtPath
(
filePath
,
isDirectory
:
&
isDirectory
)
fileManager
.
fileExists
(
atPath
:
filePath
,
isDirectory
:
&
isDirectory
)
if
!
isDirectory
{
if
!
isDirectory
.
boolValue
{
let
processedPath
=
ProcessedFilePath
(
filePathURL
:
path
,
fileName
:
path
.
lastPathComponent
)
let
processedPath
=
ProcessedFilePath
(
filePathURL
:
path
,
fileName
:
path
.
lastPathComponent
)
processedFilePaths
.
append
(
processedPath
)
processedFilePaths
.
append
(
processedPath
)
}
}
else
{
else
{
let
directoryContents
=
expandDirectoryFilePath
(
path
)
let
directoryContents
=
expandDirectoryFilePath
(
path
)
processedFilePaths
.
append
ContentsOf
(
directoryContents
)
processedFilePaths
.
append
(
contentsOf
:
directoryContents
)
}
}
}
}
return
processedFilePaths
return
processedFilePaths
...
@@ -67,28 +60,29 @@ internal class ZipUtilities {
...
@@ -67,28 +60,29 @@ internal class ZipUtilities {
- returns: Array of ProcessedFilePath structs.
- returns: Array of ProcessedFilePath structs.
*/
*/
internal
func
expandDirectoryFilePath
(
directory
:
NS
URL
)
->
[
ProcessedFilePath
]
{
internal
func
expandDirectoryFilePath
(
_
directory
:
URL
)
->
[
ProcessedFilePath
]
{
var
processedFilePaths
=
[
ProcessedFilePath
]()
var
processedFilePaths
=
[
ProcessedFilePath
]()
if
let
directoryPath
=
directory
.
path
,
let
enumerator
=
fileManager
.
enumeratorAtPath
(
directoryPath
)
{
let
directoryPath
=
directory
.
path
if
let
enumerator
=
fileManager
.
enumerator
(
atPath
:
directoryPath
)
{
while
let
filePathComponent
=
enumerator
.
nextObject
()
as?
String
{
while
let
filePathComponent
=
enumerator
.
nextObject
()
as?
String
{
let
path
=
directory
.
URLByA
ppendingPathComponent
(
filePathComponent
)
let
path
=
directory
.
a
ppendingPathComponent
(
filePathComponent
)
guard
let
filePath
=
path
.
path
,
let
directoryName
=
directory
.
lastPathComponent
else
{
let
filePath
=
path
.
path
continue
let
directoryName
=
directory
.
lastPathComponent
}
var
isDirectory
:
ObjCBool
=
false
var
isDirectory
:
ObjCBool
=
false
fileManager
.
fileExists
AtPath
(
filePath
,
isDirectory
:
&
isDirectory
)
fileManager
.
fileExists
(
atPath
:
filePath
,
isDirectory
:
&
isDirectory
)
if
!
isDirectory
{
if
!
isDirectory
.
boolValue
{
let
fileName
=
(
directoryName
as
NSString
)
.
stringByA
ppendingPathComponent
(
filePathComponent
)
let
fileName
=
(
directoryName
as
NSString
)
.
a
ppendingPathComponent
(
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
.
append
ContentsOf
(
directoryContents
)
processedFilePaths
.
append
(
contentsOf
:
directoryContents
)
}
}
}
}
}
}
return
processedFilePaths
return
processedFilePaths
}
}
}
}
\ No newline at end of file
ZipTests/ZipTests.swift
View file @
376f3efa
...
@@ -21,10 +21,10 @@ class ZipTests: XCTestCase {
...
@@ -21,10 +21,10 @@ class ZipTests: XCTestCase {
func
testQuickUnzip
()
{
func
testQuickUnzip
()
{
do
{
do
{
let
filePath
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"bb8"
,
withExtension
:
"zip"
)
!
let
filePath
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"bb8"
,
withExtension
:
"zip"
)
!
let
destinationURL
=
try
Zip
.
quickUnzipFile
(
filePath
)
let
destinationURL
=
try
Zip
.
quickUnzipFile
(
filePath
)
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
XCTAssertTrue
(
fileManager
.
fileExists
AtPath
(
destinationURL
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExists
(
atPath
:
destinationURL
.
path
))
}
}
catch
{
catch
{
XCTFail
()
XCTFail
()
...
@@ -33,11 +33,11 @@ class ZipTests: XCTestCase {
...
@@ -33,11 +33,11 @@ class ZipTests: XCTestCase {
func
testQuickUnzipNonExistingPath
()
{
func
testQuickUnzipNonExistingPath
()
{
do
{
do
{
let
filePathURL
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
resourcePath
let
filePathURL
=
Bundle
(
for
:
ZipTests
.
self
)
.
resourcePath
let
filePath
=
NSURL
(
string
:
"
\(
filePathURL
!
)
/bb9.zip"
)
let
filePath
=
NSURL
(
string
:
"
\(
filePathURL
!
)
/bb9.zip"
)
let
destinationURL
=
try
Zip
.
quickUnzipFile
(
filePath
!
)
let
destinationURL
=
try
Zip
.
quickUnzipFile
(
filePath
!
as
URL
)
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
XCTAssertFalse
(
fileManager
.
fileExists
AtPath
(
destinationURL
.
path
!
))
XCTAssertFalse
(
fileManager
.
fileExists
(
atPath
:
destinationURL
.
path
))
}
}
catch
{
catch
{
XCTAssert
(
true
)
XCTAssert
(
true
)
...
@@ -46,10 +46,10 @@ class ZipTests: XCTestCase {
...
@@ -46,10 +46,10 @@ class ZipTests: XCTestCase {
func
testQuickUnzipNonZipPath
()
{
func
testQuickUnzipNonZipPath
()
{
do
{
do
{
let
filePath
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
filePath
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
destinationURL
=
try
Zip
.
quickUnzipFile
(
filePath
)
let
destinationURL
=
try
Zip
.
quickUnzipFile
(
filePath
)
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
XCTAssertFalse
(
fileManager
.
fileExists
AtPath
(
destinationURL
.
path
!
))
XCTAssertFalse
(
fileManager
.
fileExists
(
atPath
:
destinationURL
.
path
))
}
}
catch
{
catch
{
XCTAssert
(
true
)
XCTAssert
(
true
)
...
@@ -58,8 +58,8 @@ class ZipTests: XCTestCase {
...
@@ -58,8 +58,8 @@ class ZipTests: XCTestCase {
func
testQuickUnzipProgress
()
{
func
testQuickUnzipProgress
()
{
do
{
do
{
let
filePath
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"bb8"
,
withExtension
:
"zip"
)
!
let
filePath
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"bb8"
,
withExtension
:
"zip"
)
!
try
Zip
.
quickUnzipFile
(
filePath
,
progress
:
{
(
progress
)
->
()
in
_
=
try
Zip
.
quickUnzipFile
(
filePath
,
progress
:
{
(
progress
)
->
()
in
XCTAssert
(
true
)
XCTAssert
(
true
)
})
})
}
}
...
@@ -71,9 +71,9 @@ class ZipTests: XCTestCase {
...
@@ -71,9 +71,9 @@ class ZipTests: XCTestCase {
func
testQuickUnzipOnlineURL
()
{
func
testQuickUnzipOnlineURL
()
{
do
{
do
{
let
filePath
=
NSURL
(
string
:
"http://www.google.com/google.zip"
)
!
let
filePath
=
NSURL
(
string
:
"http://www.google.com/google.zip"
)
!
let
destinationURL
=
try
Zip
.
quickUnzipFile
(
filePath
)
let
destinationURL
=
try
Zip
.
quickUnzipFile
(
filePath
as
URL
)
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
XCTAssertFalse
(
fileManager
.
fileExists
AtPath
(
destinationURL
.
path
!
))
XCTAssertFalse
(
fileManager
.
fileExists
(
atPath
:
destinationURL
.
path
))
}
}
catch
{
catch
{
XCTAssert
(
true
)
XCTAssert
(
true
)
...
@@ -82,15 +82,15 @@ class ZipTests: XCTestCase {
...
@@ -82,15 +82,15 @@ class ZipTests: XCTestCase {
func
testUnzip
()
{
func
testUnzip
()
{
do
{
do
{
let
filePath
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"bb8"
,
withExtension
:
"zip"
)
!
let
filePath
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"bb8"
,
withExtension
:
"zip"
)
!
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
U
serDomainMask
)[
0
]
as
NSURL
let
documentsFolder
=
FileManager
.
default
.
urls
(
for
:
.
documentDirectory
,
in
:
.
u
serDomainMask
)[
0
]
as
NSURL
try
Zip
.
unzipFile
(
filePath
,
destination
:
documentsFolder
,
overwrite
:
true
,
password
:
"password"
,
progress
:
{
(
progress
)
->
()
in
try
Zip
.
unzipFile
(
filePath
,
destination
:
documentsFolder
as
URL
,
overwrite
:
true
,
password
:
"password"
,
progress
:
{
(
progress
)
->
()
in
print
(
progress
)
print
(
progress
)
})
})
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
XCTAssertTrue
(
fileManager
.
fileExists
AtPath
(
documentsFolder
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExists
(
atPath
:
documentsFolder
.
path
!
))
}
}
catch
{
catch
{
XCTFail
()
XCTFail
()
...
@@ -99,14 +99,14 @@ class ZipTests: XCTestCase {
...
@@ -99,14 +99,14 @@ class ZipTests: XCTestCase {
func
testImplicitProgressUnzip
()
{
func
testImplicitProgressUnzip
()
{
do
{
do
{
let
progress
=
NS
Progress
()
let
progress
=
Progress
()
progress
.
totalUnitCount
=
1
progress
.
totalUnitCount
=
1
let
filePath
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"bb8"
,
withExtension
:
"zip"
)
!
let
filePath
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"bb8"
,
withExtension
:
"zip"
)
!
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
U
serDomainMask
)[
0
]
as
NSURL
let
documentsFolder
=
FileManager
.
default
.
urls
(
for
:
.
documentDirectory
,
in
:
.
u
serDomainMask
)[
0
]
as
NSURL
progress
.
becomeCurrent
WithPendingUnitCount
(
1
)
progress
.
becomeCurrent
(
withPendingUnitCount
:
1
)
try
Zip
.
unzipFile
(
filePath
,
destination
:
documentsFolder
,
overwrite
:
true
,
password
:
"password"
,
progress
:
nil
)
try
Zip
.
unzipFile
(
filePath
,
destination
:
documentsFolder
as
URL
,
overwrite
:
true
,
password
:
"password"
,
progress
:
nil
)
progress
.
resignCurrent
()
progress
.
resignCurrent
()
XCTAssertTrue
(
progress
.
totalUnitCount
==
progress
.
completedUnitCount
)
XCTAssertTrue
(
progress
.
totalUnitCount
==
progress
.
completedUnitCount
)
...
@@ -119,16 +119,16 @@ class ZipTests: XCTestCase {
...
@@ -119,16 +119,16 @@ class ZipTests: XCTestCase {
func
testImplicitProgressZip
()
{
func
testImplicitProgressZip
()
{
do
{
do
{
let
progress
=
NS
Progress
()
let
progress
=
Progress
()
progress
.
totalUnitCount
=
1
progress
.
totalUnitCount
=
1
let
imageURL1
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL1
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
U
serDomainMask
)[
0
]
as
NSURL
let
documentsFolder
=
FileManager
.
default
.
urls
(
for
:
.
documentDirectory
,
in
:
.
u
serDomainMask
)[
0
]
as
NSURL
let
zipFilePath
=
documentsFolder
.
URLByA
ppendingPathComponent
(
"archive.zip"
)
let
zipFilePath
=
documentsFolder
.
a
ppendingPathComponent
(
"archive.zip"
)
progress
.
becomeCurrent
WithPendingUnitCount
(
1
)
progress
.
becomeCurrent
(
withPendingUnitCount
:
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
)
...
@@ -141,11 +141,11 @@ class ZipTests: XCTestCase {
...
@@ -141,11 +141,11 @@ class ZipTests: XCTestCase {
func
testQuickZip
()
{
func
testQuickZip
()
{
do
{
do
{
let
imageURL1
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL1
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
destinationURL
=
try
Zip
.
quickZipFiles
([
imageURL1
,
imageURL2
],
fileName
:
"archive"
)
let
destinationURL
=
try
Zip
.
quickZipFiles
([
imageURL1
,
imageURL2
],
fileName
:
"archive"
)
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
XCTAssertTrue
(
fileManager
.
fileExists
AtPath
(
destinationURL
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExists
(
atPath
:
destinationURL
.
path
))
}
}
catch
{
catch
{
XCTFail
()
XCTFail
()
...
@@ -154,20 +154,20 @@ class ZipTests: XCTestCase {
...
@@ -154,20 +154,20 @@ class ZipTests: XCTestCase {
func
testQuickZipFolder
()
{
func
testQuickZipFolder
()
{
do
{
do
{
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
let
imageURL1
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL1
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
folderURL
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
bundleURL
.
URLByA
ppendingPathComponent
(
"Directory"
)
let
folderURL
=
Bundle
(
for
:
ZipTests
.
self
)
.
bundleURL
.
a
ppendingPathComponent
(
"Directory"
)
let
targetImageURL1
=
folderURL
.
URLByA
ppendingPathComponent
(
"3crBXeO.gif"
)
let
targetImageURL1
=
folderURL
.
a
ppendingPathComponent
(
"3crBXeO.gif"
)
let
targetImageURL2
=
folderURL
.
URLByA
ppendingPathComponent
(
"kYkLkPf.gif"
)
let
targetImageURL2
=
folderURL
.
a
ppendingPathComponent
(
"kYkLkPf.gif"
)
if
fileManager
.
fileExists
AtPath
(
folderURL
.
path
!
)
{
if
fileManager
.
fileExists
(
atPath
:
folderURL
.
path
)
{
try
fileManager
.
removeItem
AtURL
(
folderURL
)
try
fileManager
.
removeItem
(
at
:
folderURL
)
}
}
try
fileManager
.
createDirectory
AtURL
(
folderURL
,
withIntermediateDirectories
:
false
,
attributes
:
nil
)
try
fileManager
.
createDirectory
(
at
:
folderURL
,
withIntermediateDirectories
:
false
,
attributes
:
nil
)
try
fileManager
.
copyItem
AtURL
(
imageURL1
,
toURL
:
targetImageURL1
)
try
fileManager
.
copyItem
(
at
:
imageURL1
,
to
:
targetImageURL1
)
try
fileManager
.
copyItem
AtURL
(
imageURL2
,
toURL
:
targetImageURL2
)
try
fileManager
.
copyItem
(
at
:
imageURL2
,
to
:
targetImageURL2
)
let
destinationURL
=
try
Zip
.
quickZipFiles
([
folderURL
],
fileName
:
"directory"
)
let
destinationURL
=
try
Zip
.
quickZipFiles
([
folderURL
],
fileName
:
"directory"
)
XCTAssertTrue
(
fileManager
.
fileExists
AtPath
(
destinationURL
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExists
(
atPath
:
destinationURL
.
path
))
}
}
catch
{
catch
{
XCTFail
()
XCTFail
()
...
@@ -177,15 +177,15 @@ class ZipTests: XCTestCase {
...
@@ -177,15 +177,15 @@ class ZipTests: XCTestCase {
func
testZip
()
{
func
testZip
()
{
do
{
do
{
let
imageURL1
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL1
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
U
serDomainMask
)[
0
]
as
NSURL
let
documentsFolder
=
FileManager
.
default
.
urls
(
for
:
.
documentDirectory
,
in
:
.
u
serDomainMask
)[
0
]
as
NSURL
let
zipFilePath
=
documentsFolder
.
URLByA
ppendingPathComponent
(
"archive.zip"
)
let
zipFilePath
=
documentsFolder
.
a
ppendingPathComponent
(
"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
=
FileManager
.
default
XCTAssertTrue
(
fileManager
.
fileExists
AtPath
(
zipFilePath
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExists
(
atPath
:(
zipFilePath
?
.
path
)
!
))
}
}
catch
{
catch
{
XCTFail
()
XCTFail
()
...
@@ -194,23 +194,23 @@ class ZipTests: XCTestCase {
...
@@ -194,23 +194,23 @@ class ZipTests: XCTestCase {
func
testZipUnzipPassword
()
{
func
testZipUnzipPassword
()
{
do
{
do
{
let
imageURL1
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL1
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"3crBXeO"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
imageURL2
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"kYkLkPf"
,
withExtension
:
"gif"
)
!
let
documentsFolder
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
U
serDomainMask
)[
0
]
as
NSURL
let
documentsFolder
=
FileManager
.
default
.
urls
(
for
:
.
documentDirectory
,
in
:
.
u
serDomainMask
)[
0
]
as
NSURL
let
zipFilePath
=
documentsFolder
.
URLByA
ppendingPathComponent
(
"archive.zip"
)
let
zipFilePath
=
documentsFolder
.
a
ppendingPathComponent
(
"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
=
FileManager
.
default
XCTAssertTrue
(
fileManager
.
fileExists
AtPath
(
zipFilePath
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExists
(
atPath
:(
zipFilePath
?
.
path
)
!
))
guard
let
fileExtension
=
zipFilePath
.
pathExtension
,
let
fileName
=
zipFilePath
.
lastPathComponent
else
{
guard
let
fileExtension
=
zipFilePath
?
.
pathExtension
,
let
fileName
=
zipFilePath
?
.
lastPathComponent
else
{
throw
ZipError
.
U
nzipFail
throw
ZipError
.
u
nzipFail
}
}
let
directoryName
=
fileName
.
stringByReplacingOccurrencesOfString
(
".
\(
fileExtension
)
"
,
withString
:
""
)
let
directoryName
=
fileName
.
replacingOccurrences
(
of
:
".
\(
fileExtension
)
"
,
with
:
""
)
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
U
serDomainMask
)[
0
]
as
NSURL
let
documentsUrl
=
fileManager
.
urls
(
for
:
.
documentDirectory
,
in
:
.
u
serDomainMask
)[
0
]
as
NSURL
let
destinationUrl
=
documentsUrl
.
URLByA
ppendingPathComponent
(
directoryName
,
isDirectory
:
true
)
let
destinationUrl
=
documentsUrl
.
a
ppendingPathComponent
(
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
.
fileExists
AtPath
(
destinationUrl
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExists
(
atPath
:(
destinationUrl
?
.
path
)
!
))
}
}
catch
{
catch
{
XCTFail
()
XCTFail
()
...
@@ -220,16 +220,15 @@ class ZipTests: XCTestCase {
...
@@ -220,16 +220,15 @@ class ZipTests: XCTestCase {
func
testQuickUnzipSubDir
()
{
func
testQuickUnzipSubDir
()
{
do
{
do
{
let
bookURL
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"bb8"
,
withExtension
:
"zip"
)
!
let
bookURL
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"bb8"
,
withExtension
:
"zip"
)
!
let
unzipDestination
=
try
Zip
.
quickUnzipFile
(
bookURL
)
let
unzipDestination
=
try
Zip
.
quickUnzipFile
(
bookURL
)
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
let
subDir
=
unzipDestination
.
appendingPathComponent
(
"subDir"
)
let
subDir
=
unzipDestination
.
URLByAppendingPathComponent
(
"subDir"
)
let
imageURL
=
subDir
.
appendingPathComponent
(
"r2W9yu9"
)
.
appendingPathExtension
(
"gif"
)
let
imageURL
=
subDir
.
URLByAppendingPathComponent
(
"r2W9yu9"
)
.
URLByAppendingPathExtension
(
"gif"
)
XCTAssertTrue
(
fileManager
.
fileExists
AtPath
(
unzipDestination
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExists
(
atPath
:
unzipDestination
.
path
))
XCTAssertTrue
(
fileManager
.
fileExists
AtPath
(
subDir
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExists
(
atPath
:
subDir
.
path
))
XCTAssertTrue
(
fileManager
.
fileExists
AtPath
(
imageURL
.
path
!
))
XCTAssertTrue
(
fileManager
.
fileExists
(
atPath
:
imageURL
.
path
))
}
catch
{
}
catch
{
XCTFail
()
XCTFail
()
}
}
...
...
build.sh
View file @
376f3efa
#!/bin/bash
#!/bin/bash
# **** Update me when new Xcode versions are released! ****
# **** Update me when new Xcode versions are released! ****
PLATFORM
=
"platform=iOS Simulator,OS=
9.2,name=iPhone 6
"
PLATFORM
=
"platform=iOS Simulator,OS=
10.0,name=iPhone 6s
"
SDK
=
"iphonesimulator
9.2
"
SDK
=
"iphonesimulator
10.0
"
# It is pitch black.
# It is pitch black.
...
@@ -19,12 +19,12 @@ MODE="$1"
...
@@ -19,12 +19,12 @@ MODE="$1"
if
[
"
$MODE
"
=
"framework"
]
;
then
if
[
"
$MODE
"
=
"framework"
]
;
then
echo
"Building and testing Zip."
echo
"Building and testing Zip."
xc
tool
\
xc
odebuild
\
-project
Zip.xcodeproj
\
-project
Zip.xcodeproj
\
-scheme
Zip
\
-scheme
Zip
\
-sdk
"
$SDK
"
\
-sdk
"
$SDK
"
\
-destination
"
$PLATFORM
"
\
-destination
"
$PLATFORM
"
\
build
test
test
trap
- EXIT
trap
- EXIT
exit
0
exit
0
fi
fi
...
@@ -35,12 +35,11 @@ if [ "$MODE" = "examples" ]; then
...
@@ -35,12 +35,11 @@ if [ "$MODE" = "examples" ]; then
for
example
in
examples/
*
/
;
do
for
example
in
examples/
*
/
;
do
echo
"Building
$example
."
echo
"Building
$example
."
pod
install
--project-directory
=
$example
pod
install
--project-directory
=
$example
xc
tool
\
xc
odebuild
\
-workspace
"
${
example
}
Sample.xcworkspace"
\
-workspace
"
${
example
}
Sample.xcworkspace"
\
-scheme
Sample
\
-scheme
Sample
\
-sdk
"
$SDK
"
\
-sdk
"
$SDK
"
\
-destination
"
$PLATFORM
"
\
-destination
"
$PLATFORM
"
build
done
done
trap
- EXIT
trap
- EXIT
exit
0
exit
0
...
...
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