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
Expand all
Show 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
#
build/
...
...
.travis.yml
View file @
376f3efa
osx_image
:
xcode
7.2
osx_image
:
xcode
8
language
:
objective-c
env
:
global
:
...
...
@@ -6,9 +6,7 @@ env:
-
LANG=en_US.UTF-8
before_install
:
-
brew update || brew update
-
brew outdated xctool || brew upgrade xctool
-
gem install cocoapods
-
xcrun simctl list
install
:
echo "<3"
env
:
-
MODE=framework
...
...
@@ -19,3 +17,4 @@ script: ./build.sh $MODE
branches
:
only
:
-
master
-
swift3.0
Zip.xcodeproj/project.pbxproj
View file @
376f3efa
...
...
@@ -493,7 +493,7 @@
isa
=
PBXProject
;
attributes
=
{
LastSwiftUpdateCheck
=
0720
;
LastUpgradeCheck
=
0
72
0
;
LastUpgradeCheck
=
0
80
0
;
ORGANIZATIONNAME
=
"Roy Marmelstein"
;
TargetAttributes
=
{
343F50FE1C8DAEEC0028C434
=
{
...
...
@@ -504,9 +504,11 @@
};
347E3A731C1DFFB500A11FD3
=
{
CreatedOnToolsVersion
=
7.2
;
LastSwiftMigration
=
0800
;
};
347E3A7D1C1DFFB500A11FD3
=
{
CreatedOnToolsVersion
=
7.2
;
LastSwiftMigration
=
0800
;
};
};
};
...
...
@@ -714,6 +716,7 @@
SKIP_INSTALL
=
YES
;
SUPPORTED_PLATFORMS
=
"appletvsimulator appletvos"
;
SWIFT_INCLUDE_PATHS
=
"${SRCROOT}/Zip/minizip/**"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
TARGETED_DEVICE_FAMILY
=
3
;
TVOS_DEPLOYMENT_TARGET
=
9.0
;
};
...
...
@@ -762,6 +765,7 @@
SDKROOT
=
macosx
;
SKIP_INSTALL
=
YES
;
SWIFT_INCLUDE_PATHS
=
"${SRCROOT}/Zip/minizip/**"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
};
name
=
Release
;
};
...
...
@@ -901,6 +905,7 @@
SKIP_INSTALL
=
YES
;
SWIFT_INCLUDE_PATHS
=
"${SRCROOT}/Zip/minizip/**"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Onone"
;
SWIFT_VERSION
=
3.0
;
};
name
=
Debug
;
};
...
...
@@ -922,6 +927,8 @@
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
SKIP_INSTALL
=
YES
;
SWIFT_INCLUDE_PATHS
=
"${SRCROOT}/Zip/minizip/**"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
SWIFT_VERSION
=
3.0
;
};
name
=
Release
;
};
...
...
@@ -932,6 +939,7 @@
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.roymarmelstein.ZipTests
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
SWIFT_VERSION
=
3.0
;
};
name
=
Debug
;
};
...
...
@@ -942,6 +950,8 @@
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.roymarmelstein.ZipTests
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
SWIFT_OPTIMIZATION_LEVEL
=
"-Owholemodule"
;
SWIFT_VERSION
=
3.0
;
};
name
=
Release
;
};
...
...
Zip.xcodeproj/project.xcworkspace/xcshareddata/Zip.xcscmblueprint
View file @
376f3efa
...
...
@@ -10,7 +10,7 @@
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "F3707899-72AE-49DA-9BDD-5CB0B64CF03A",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"8DA5B175D3FDB92A3B3CCBD4109A734F1316A3DD" : "Zip\/Zip\/minizip\/",
"3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4" : "Zip\/"
"3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4" : "Zip
-swift3
\/"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "Zip",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
...
...
Zip.xcodeproj/xcshareddata/xcschemes/Zip OSX.xcscheme
View file @
376f3efa
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"0
72
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
<BuildAction
parallelizeBuildables =
"YES"
...
...
Zip.xcodeproj/xcshareddata/xcschemes/Zip tvOS.xcscheme
View file @
376f3efa
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"0
73
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
<BuildAction
parallelizeBuildables =
"YES"
...
...
Zip.xcodeproj/xcshareddata/xcschemes/Zip.xcscheme
View file @
376f3efa
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"0
72
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
<BuildAction
parallelizeBuildables =
"YES"
...
...
Zip.xcodeproj/xcshareddata/xcschemes/ZipTests.xcscheme
View file @
376f3efa
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"0
72
0"
LastUpgradeVersion =
"0
80
0"
version =
"1.3"
>
<BuildAction
parallelizeBuildables =
"YES"
...
...
Zip/QuickZip.swift
View file @
376f3efa
...
...
@@ -21,7 +21,7 @@ extension Zip {
- 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
)
}
...
...
@@ -37,16 +37,21 @@ extension Zip {
- returns: NSURL of the destination folder.
*/
public
class
func
quickUnzipFile
(
path
:
NSURL
,
progress
:
((
progress
:
Double
)
->
())?)
throws
->
NSURL
{
let
fileManager
=
NSFileManager
.
defaultManager
()
guard
let
fileExtension
=
path
.
pathExtension
,
let
fileName
=
path
.
lastPathComponent
else
{
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
)
public
class
func
quickUnzipFile
(
_
path
:
URL
,
progress
:
((
progress
:
Double
)
->
())?)
throws
->
URL
{
let
fileManager
=
FileManager
.
default
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
)
}
}
//MARK: Quick Zip
...
...
@@ -63,7 +68,7 @@ extension Zip {
- 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
)
}
...
...
@@ -80,10 +85,10 @@ extension Zip {
- returns: NSURL of the destination folder.
*/
public
class
func
quickZipFiles
(
paths
:
[
NSURL
],
fileName
:
String
,
progress
:
((
progress
:
Double
)
->
())?)
throws
->
NS
URL
{
let
fileManager
=
NSFileManager
.
defaultManager
()
let
documentsUrl
=
fileManager
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NS
URL
let
destinationUrl
=
documentsUrl
.
URLByA
ppendingPathComponent
(
"
\(
fileName
)
.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
destinationUrl
=
try!
documentsUrl
.
a
ppendingPathComponent
(
"
\(
fileName
)
.zip"
)
try
self
.
zipFiles
(
paths
,
zipFilePath
:
destinationUrl
,
password
:
nil
,
progress
:
progress
)
return
destinationUrl
}
...
...
Zip/Zip.swift
View file @
376f3efa
This diff is collapsed.
Click to expand it.
Zip/ZipUtilities.swift
View file @
376f3efa
...
...
@@ -11,22 +11,17 @@ import Foundation
internal
class
ZipUtilities
{
// File manager
let
fileManager
=
NSFileManager
.
defaultManager
()
let
fileManager
=
FileManager
.
default
/**
* ProcessedFilePath struct
*/
internal
struct
ProcessedFilePath
{
let
filePathURL
:
NS
URL
let
filePathURL
:
URL
let
fileName
:
String
?
func
filePath
()
->
String
{
if
let
filePath
=
filePathURL
.
path
{
return
filePath
}
else
{
return
String
()
}
return
filePathURL
.
path
}
}
...
...
@@ -39,21 +34,19 @@ internal class ZipUtilities {
- returns: Array of ProcessedFilePath structs.
*/
internal
func
processZipPaths
(
paths
:
[
NS
URL
])
->
[
ProcessedFilePath
]{
internal
func
processZipPaths
(
_
paths
:
[
URL
])
->
[
ProcessedFilePath
]{
var
processedFilePaths
=
[
ProcessedFilePath
]()
for
path
in
paths
{
guard
let
filePath
=
path
.
path
else
{
continue
}
let
filePath
=
path
.
path
var
isDirectory
:
ObjCBool
=
false
fileManager
.
fileExists
AtPath
(
filePath
,
isDirectory
:
&
isDirectory
)
if
!
isDirectory
{
fileManager
.
fileExists
(
atPath
:
filePath
,
isDirectory
:
&
isDirectory
)
if
!
isDirectory
.
boolValue
{
let
processedPath
=
ProcessedFilePath
(
filePathURL
:
path
,
fileName
:
path
.
lastPathComponent
)
processedFilePaths
.
append
(
processedPath
)
}
else
{
let
directoryContents
=
expandDirectoryFilePath
(
path
)
processedFilePaths
.
append
ContentsOf
(
directoryContents
)
processedFilePaths
.
append
(
contentsOf
:
directoryContents
)
}
}
return
processedFilePaths
...
...
@@ -67,24 +60,25 @@ internal class ZipUtilities {
- returns: Array of ProcessedFilePath structs.
*/
internal
func
expandDirectoryFilePath
(
directory
:
NS
URL
)
->
[
ProcessedFilePath
]
{
internal
func
expandDirectoryFilePath
(
_
directory
:
URL
)
->
[
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
{
let
path
=
directory
.
URLByA
ppendingPathComponent
(
filePathComponent
)
guard
let
filePath
=
path
.
path
,
let
directoryName
=
directory
.
lastPathComponent
else
{
continue
}
let
path
=
directory
.
a
ppendingPathComponent
(
filePathComponent
)
let
filePath
=
path
.
path
let
directoryName
=
directory
.
lastPathComponent
var
isDirectory
:
ObjCBool
=
false
fileManager
.
fileExists
AtPath
(
filePath
,
isDirectory
:
&
isDirectory
)
if
!
isDirectory
{
let
fileName
=
(
directoryName
as
NSString
)
.
stringByA
ppendingPathComponent
(
filePathComponent
)
fileManager
.
fileExists
(
atPath
:
filePath
,
isDirectory
:
&
isDirectory
)
if
!
isDirectory
.
boolValue
{
let
fileName
=
(
directoryName
as
NSString
)
.
a
ppendingPathComponent
(
filePathComponent
)
let
processedPath
=
ProcessedFilePath
(
filePathURL
:
path
,
fileName
:
fileName
)
processedFilePaths
.
append
(
processedPath
)
}
else
{
let
directoryContents
=
expandDirectoryFilePath
(
path
)
processedFilePaths
.
append
ContentsOf
(
directoryContents
)
processedFilePaths
.
append
(
contentsOf
:
directoryContents
)
}
}
}
...
...
ZipTests/ZipTests.swift
View file @
376f3efa
This diff is collapsed.
Click to expand it.
build.sh
View file @
376f3efa
#!/bin/bash
# **** Update me when new Xcode versions are released! ****
PLATFORM
=
"platform=iOS Simulator,OS=
9.2,name=iPhone 6
"
SDK
=
"iphonesimulator
9.2
"
PLATFORM
=
"platform=iOS Simulator,OS=
10.0,name=iPhone 6s
"
SDK
=
"iphonesimulator
10.0
"
# It is pitch black.
...
...
@@ -19,12 +19,12 @@ MODE="$1"
if
[
"
$MODE
"
=
"framework"
]
;
then
echo
"Building and testing Zip."
xc
tool
\
xc
odebuild
\
-project
Zip.xcodeproj
\
-scheme
Zip
\
-sdk
"
$SDK
"
\
-destination
"
$PLATFORM
"
\
build
test
test
trap
- EXIT
exit
0
fi
...
...
@@ -35,12 +35,11 @@ if [ "$MODE" = "examples" ]; then
for
example
in
examples/
*
/
;
do
echo
"Building
$example
."
pod
install
--project-directory
=
$example
xc
tool
\
xc
odebuild
\
-workspace
"
${
example
}
Sample.xcworkspace"
\
-scheme
Sample
\
-sdk
"
$SDK
"
\
-destination
"
$PLATFORM
"
\
build
-destination
"
$PLATFORM
"
done
trap
- EXIT
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