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
7b888c22
Commit
7b888c22
authored
Jan 15, 2016
by
Roy Marmelstein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Zip improvements
parent
550a0606
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
11 deletions
+18
-11
Zip.xcodeproj/project.pbxproj
Zip.xcodeproj/project.pbxproj
+2
-2
Zip/Zip.swift
Zip/Zip.swift
+14
-4
Zip/module.modulemap
Zip/module.modulemap
+0
-5
examples/Sample/Sample/ViewController.swift
examples/Sample/Sample/ViewController.swift
+2
-0
No files found.
Zip.xcodeproj/project.pbxproj
View file @
7b888c22
...
@@ -74,7 +74,6 @@
...
@@ -74,7 +74,6 @@
3430BB231C484A65001143B5
/* pwd2key.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
pwd2key.h
;
sourceTree
=
"<group>"
;
};
3430BB231C484A65001143B5
/* pwd2key.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
pwd2key.h
;
sourceTree
=
"<group>"
;
};
3430BB241C484A65001143B5
/* sha1.c */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.c
;
path
=
sha1.c
;
sourceTree
=
"<group>"
;
};
3430BB241C484A65001143B5
/* sha1.c */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.c
;
path
=
sha1.c
;
sourceTree
=
"<group>"
;
};
3430BB251C484A65001143B5
/* sha1.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
sha1.h
;
sourceTree
=
"<group>"
;
};
3430BB251C484A65001143B5
/* sha1.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
sha1.h
;
sourceTree
=
"<group>"
;
};
3430BB3E1C484D39001143B5
/* module.modulemap */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
"sourcecode.module-map"
;
name
=
module.modulemap
;
path
=
Zip/module.modulemap
;
sourceTree
=
SOURCE_ROOT
;
};
3430F61F1C45C805007473A6
/* libz.tbd */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"sourcecode.text-based-dylib-definition"
;
name
=
libz.tbd
;
path
=
usr/lib/libz.tbd
;
sourceTree
=
SDKROOT
;
};
3430F61F1C45C805007473A6
/* libz.tbd */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"sourcecode.text-based-dylib-definition"
;
name
=
libz.tbd
;
path
=
usr/lib/libz.tbd
;
sourceTree
=
SDKROOT
;
};
3430F6221C45C851007473A6
/* crypt.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
crypt.h
;
sourceTree
=
"<group>"
;
};
3430F6221C45C851007473A6
/* crypt.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
crypt.h
;
sourceTree
=
"<group>"
;
};
3430F6241C45C851007473A6
/* ioapi.c */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.c
;
path
=
ioapi.c
;
sourceTree
=
"<group>"
;
};
3430F6241C45C851007473A6
/* ioapi.c */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.c
;
path
=
ioapi.c
;
sourceTree
=
"<group>"
;
};
...
@@ -83,6 +82,7 @@
...
@@ -83,6 +82,7 @@
3430F62A1C45C851007473A6
/* unzip.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
unzip.h
;
sourceTree
=
"<group>"
;
};
3430F62A1C45C851007473A6
/* unzip.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
unzip.h
;
sourceTree
=
"<group>"
;
};
3430F62B1C45C851007473A6
/* zip.c */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.c
;
path
=
zip.c
;
sourceTree
=
"<group>"
;
};
3430F62B1C45C851007473A6
/* zip.c */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.c
;
path
=
zip.c
;
sourceTree
=
"<group>"
;
};
3430F62C1C45C851007473A6
/* zip.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
zip.h
;
sourceTree
=
"<group>"
;
};
3430F62C1C45C851007473A6
/* zip.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
zip.h
;
sourceTree
=
"<group>"
;
};
3433BFCD1C48D3EC006DF000
/* module.modulemap */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
"sourcecode.module-map"
;
path
=
module.modulemap
;
sourceTree
=
"<group>"
;
};
347E3A741C1DFFB500A11FD3
/* Zip.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
Zip.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
347E3A741C1DFFB500A11FD3
/* Zip.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
Zip.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
347E3A771C1DFFB500A11FD3
/* Zip.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
Zip.h
;
sourceTree
=
"<group>"
;
};
347E3A771C1DFFB500A11FD3
/* Zip.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
Zip.h
;
sourceTree
=
"<group>"
;
};
347E3A791C1DFFB500A11FD3
/* Info.plist */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.xml
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
347E3A791C1DFFB500A11FD3
/* Info.plist */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.xml
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
...
@@ -146,9 +146,9 @@
...
@@ -146,9 +146,9 @@
3430BB0F1C484A65001143B5
/* aes */
,
3430BB0F1C484A65001143B5
/* aes */
,
3430F6221C45C851007473A6
/* crypt.h */
,
3430F6221C45C851007473A6
/* crypt.h */
,
3430F6241C45C851007473A6
/* ioapi.c */
,
3430F6241C45C851007473A6
/* ioapi.c */
,
3433BFCD1C48D3EC006DF000
/* module.modulemap */
,
3430F6251C45C851007473A6
/* ioapi.h */
,
3430F6251C45C851007473A6
/* ioapi.h */
,
3430F6291C45C851007473A6
/* unzip.c */
,
3430F6291C45C851007473A6
/* unzip.c */
,
3430BB3E1C484D39001143B5
/* module.modulemap */
,
3430F62A1C45C851007473A6
/* unzip.h */
,
3430F62A1C45C851007473A6
/* unzip.h */
,
3430F62B1C45C851007473A6
/* zip.c */
,
3430F62B1C45C851007473A6
/* zip.c */
,
3430F62C1C45C851007473A6
/* zip.h */
,
3430F62C1C45C851007473A6
/* zip.h */
,
...
...
Zip/Zip.swift
View file @
7b888c22
...
@@ -157,11 +157,13 @@ public class Zip {
...
@@ -157,11 +157,13 @@ public class Zip {
Quick zip files.
Quick zip files.
- parameter paths: Array of NSURL filepaths.
- parameter paths: Array of NSURL filepaths.
- parameter fileName: File name for the resulting zip file.
- throws: rror if zipping fails.
- throws: rror if zipping fails.
*/
*/
public
func
zipFiles
(
paths
:
[
NSURL
])
throws
{
public
func
zipFiles
(
paths
:
[
NSURL
],
fileName
:
String
)
throws
{
let
documentsUrl
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
var
documentsUrl
=
NSFileManager
.
defaultManager
()
.
URLsForDirectory
(
.
DocumentDirectory
,
inDomains
:
.
UserDomainMask
)[
0
]
as
NSURL
documentsUrl
=
documentsUrl
.
URLByAppendingPathComponent
(
"
\(
fileName
)
.zip"
)
try
self
.
zipFiles
(
paths
,
destination
:
documentsUrl
,
password
:
nil
)
try
self
.
zipFiles
(
paths
,
destination
:
documentsUrl
,
password
:
nil
)
}
}
...
@@ -198,7 +200,15 @@ public class Zip {
...
@@ -198,7 +200,15 @@ public class Zip {
}
}
catch
{}
catch
{}
let
buffer
=
malloc
(
chunkSize
)
let
buffer
=
malloc
(
chunkSize
)
zipOpenNewFileInZip3
(
zip
,
fileName
!
,
&
zipInfo
,
nil
,
0
,
nil
,
0
,
nil
,
Z_DEFLATED
,
Z_DEFAULT_COMPRESSION
,
0
,
-
MAX_WBITS
,
DEF_MEM_LEVEL
,
Z_DEFAULT_STRATEGY
,
password
!
,
0
)
if
let
password
=
password
,
let
fileName
=
fileName
{
zipOpenNewFileInZip3
(
zip
,
fileName
,
&
zipInfo
,
nil
,
0
,
nil
,
0
,
nil
,
Z_DEFLATED
,
Z_DEFAULT_COMPRESSION
,
0
,
-
MAX_WBITS
,
DEF_MEM_LEVEL
,
Z_DEFAULT_STRATEGY
,
password
,
0
)
}
else
if
let
fileName
=
fileName
{
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
{
throw
ZipError
.
ZipError
}
var
len
:
Int
=
0
var
len
:
Int
=
0
while
(
feof
(
input
)
==
0
)
{
while
(
feof
(
input
)
==
0
)
{
len
=
fread
(
buffer
,
1
,
chunkSize
,
input
)
len
=
fread
(
buffer
,
1
,
chunkSize
,
input
)
...
...
Zip/module.modulemap
deleted
100644 → 0
View file @
550a0606
module minizip [system][extern_c] {
header "unzip.h"
header "zip.h"
export *
}
examples/Sample/Sample/ViewController.swift
View file @
7b888c22
...
@@ -19,6 +19,8 @@ class ViewController: UIViewController {
...
@@ -19,6 +19,8 @@ class ViewController: UIViewController {
let
fileAbsoluteURL
=
NSURL
(
string
:
fileAbsolutePath
!
)
!
let
fileAbsoluteURL
=
NSURL
(
string
:
fileAbsolutePath
!
)
!
print
(
destinationPath
)
print
(
destinationPath
)
try
Zip
()
.
unzipFile
(
fileAbsoluteURL
)
try
Zip
()
.
unzipFile
(
fileAbsoluteURL
)
try
Zip
()
.
zipFiles
([
fileAbsoluteURL
],
fileName
:
"zipTest"
)
}
}
catch
{
catch
{
print
(
"oops"
)
print
(
"oops"
)
...
...
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