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
c29f08bc
Commit
c29f08bc
authored
Jan 16, 2016
by
Roy Marmelstein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding quick unzip test and fixing path bug
parent
1081f87f
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
57 additions
and
15 deletions
+57
-15
Zip.xcodeproj/project.pbxproj
Zip.xcodeproj/project.pbxproj
+12
-0
Zip.xcodeproj/project.xcworkspace/xcshareddata/Zip.xcscmblueprint
...eproj/project.xcworkspace/xcshareddata/Zip.xcscmblueprint
+30
-0
Zip/QuickZip.swift
Zip/QuickZip.swift
+1
-1
Zip/Zip.swift
Zip/Zip.swift
+3
-3
ZipTests/3crBXeO.gif
ZipTests/3crBXeO.gif
+0
-0
ZipTests/ZipTests.swift
ZipTests/ZipTests.swift
+11
-11
ZipTests/bb8.zip
ZipTests/bb8.zip
+0
-0
ZipTests/kYkLkPf.gif
ZipTests/kYkLkPf.gif
+0
-0
No files found.
Zip.xcodeproj/project.pbxproj
View file @
c29f08bc
...
...
@@ -37,6 +37,9 @@
3430F6351C45C851007473A6
/* zip.c in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3430F62B1C45C851007473A6
/* zip.c */
;
};
3430F6361C45C851007473A6
/* zip.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3430F62C1C45C851007473A6
/* zip.h */
;
};
3443A3F61C4AB8A3004AD173
/* QuickZip.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3443A3F51C4AB8A3004AD173
/* QuickZip.swift */
;
};
3443A3F91C4AD169004AD173
/* kYkLkPf.gif in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3443A3F81C4AD169004AD173
/* kYkLkPf.gif */
;
};
3443A3FB1C4AD16F004AD173
/* 3crBXeO.gif in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3443A3FA1C4AD16F004AD173
/* 3crBXeO.gif */
;
};
3443A3FD1C4AD199004AD173
/* bb8.zip in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3443A3FC1C4AD199004AD173
/* bb8.zip */
;
};
347E3A781C1DFFB500A11FD3
/* Zip.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
347E3A771C1DFFB500A11FD3
/* Zip.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
347E3A7F1C1DFFB500A11FD3
/* Zip.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
347E3A741C1DFFB500A11FD3
/* Zip.framework */
;
};
347E3A841C1DFFB500A11FD3
/* ZipTests.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
347E3A831C1DFFB500A11FD3
/* ZipTests.swift */
;
};
...
...
@@ -85,6 +88,9 @@
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>"
;
};
3443A3F51C4AB8A3004AD173
/* QuickZip.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
QuickZip.swift
;
sourceTree
=
"<group>"
;
};
3443A3F81C4AD169004AD173
/* kYkLkPf.gif */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
image.gif
;
path
=
kYkLkPf.gif
;
sourceTree
=
"<group>"
;
};
3443A3FA1C4AD16F004AD173
/* 3crBXeO.gif */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
image.gif
;
path
=
3crBXeO.gif
;
sourceTree
=
"<group>"
;
};
3443A3FC1C4AD199004AD173
/* bb8.zip */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
archive.zip
;
path
=
bb8.zip
;
sourceTree
=
"<group>"
;
};
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>"
;
};
347E3A791C1DFFB500A11FD3
/* Info.plist */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.xml
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
...
...
@@ -192,6 +198,9 @@
347E3A821C1DFFB500A11FD3
/* ZipTests */
=
{
isa
=
PBXGroup
;
children
=
(
3443A3FA1C4AD16F004AD173
/* 3crBXeO.gif */
,
3443A3F81C4AD169004AD173
/* kYkLkPf.gif */
,
3443A3FC1C4AD199004AD173
/* bb8.zip */
,
347E3A831C1DFFB500A11FD3
/* ZipTests.swift */
,
347E3A851C1DFFB500A11FD3
/* Info.plist */
,
);
...
...
@@ -312,6 +321,9 @@
isa
=
PBXResourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
3443A3FD1C4AD199004AD173
/* bb8.zip in Resources */
,
3443A3F91C4AD169004AD173
/* kYkLkPf.gif in Resources */
,
3443A3FB1C4AD16F004AD173
/* 3crBXeO.gif in Resources */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
Zip.xcodeproj/project.xcworkspace/xcshareddata/Zip.xcscmblueprint
0 → 100644
View file @
c29f08bc
{
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"8DA5B175D3FDB92A3B3CCBD4109A734F1316A3DD" : 0,
"3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4" : 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "F3707899-72AE-49DA-9BDD-5CB0B64CF03A",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"8DA5B175D3FDB92A3B3CCBD4109A734F1316A3DD" : "Zip\/Zip\/minizip\/",
"3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4" : "Zip\/"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "Zip",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "Zip.xcodeproj",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/marmelroy\/Zip.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/marmelroy\/minizip.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "8DA5B175D3FDB92A3B3CCBD4109A734F1316A3DD"
}
]
}
\ No newline at end of file
Zip/QuickZip.swift
View file @
c29f08bc
...
...
@@ -39,7 +39,7 @@ extension Zip {
guard
let
fileExtension
=
path
.
pathExtension
,
let
fileName
=
path
.
lastPathComponent
else
{
throw
ZipError
.
UnzipFail
}
let
directoryName
=
fileName
.
stringByReplacingOccurrencesOfString
(
fileExtension
,
withString
:
""
)
let
directoryName
=
fileName
.
stringByReplacingOccurrencesOfString
(
".
\(
fileExtension
)
"
,
withString
:
""
)
let
destinationUrl
=
documentsUrl
.
URLByAppendingPathComponent
(
directoryName
,
isDirectory
:
true
)
try
self
.
unzipFile
(
path
,
destination
:
destinationUrl
,
overwrite
:
true
,
password
:
nil
,
progress
:
progress
)
return
destinationUrl
...
...
Zip/Zip.swift
View file @
c29f08bc
...
...
@@ -57,7 +57,7 @@ public class Zip {
public
func
unzipFile
(
path
:
NSURL
,
destination
:
NSURL
,
overwrite
:
Bool
,
password
:
String
?,
progress
:
((
progress
:
Double
)
->
())?)
throws
{
// Check whether a zip file exists at path.
let
fileManager
=
NSFileManager
.
defaultManager
()
if
fileManager
.
fileExistsAtPath
(
path
.
absoluteString
)
==
false
||
path
.
pathExtension
!=
".
zip"
{
if
fileManager
.
fileExistsAtPath
(
path
.
path
!
)
==
false
||
path
.
pathExtension
!=
"
zip"
{
throw
ZipError
.
FileNotFound
}
// Unzip set up
...
...
@@ -66,9 +66,9 @@ public class Zip {
let
bufferSize
:
UInt32
=
4096
var
buffer
=
Array
<
CUnsignedChar
>
(
count
:
Int
(
bufferSize
),
repeatedValue
:
0
)
// Begin unzipping
let
zip
=
unzOpen64
(
path
.
absoluteString
)
let
zip
=
unzOpen64
(
path
.
path
!
)
let
fileAttributes
=
try
fileManager
.
attributesOfItemAtPath
(
path
.
absoluteString
)
let
fileAttributes
=
try
fileManager
.
attributesOfItemAtPath
(
path
.
path
!
)
let
totalSize
=
fileAttributes
[
NSFileSize
]
as?
Double
var
currentPosition
:
Double
=
0.0
if
unzGoToFirstFile
(
zip
)
!=
UNZ_OK
{
...
...
ZipTests/3crBXeO.gif
0 → 100644
View file @
c29f08bc
843 KB
ZipTests/ZipTests.swift
View file @
c29f08bc
...
...
@@ -13,24 +13,24 @@ class ZipTests: XCTestCase {
override
func
setUp
()
{
super
.
setUp
()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override
func
tearDown
()
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
super
.
tearDown
()
}
func
testExample
()
{
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
func
testQuickUnzip
()
{
do
{
let
fileAbsoluteURL
=
NSBundle
(
forClass
:
ZipTests
.
self
)
.
URLForResource
(
"bb8"
,
withExtension
:
"zip"
)
!
let
destinationURL
=
try
Zip
()
.
quickUnzipFile
(
fileAbsoluteURL
)
let
fileManager
=
NSFileManager
.
defaultManager
()
XCTAssertTrue
(
fileManager
.
fileExistsAtPath
(
destinationURL
.
path
!
))
}
func
testPerformanceExample
()
{
// This is an example of a performance test case.
self
.
measureBlock
{
// Put the code you want to measure the time of here.
catch
{
XCTFail
()
}
}
}
ZipTests/bb8.zip
0 → 100644
View file @
c29f08bc
File added
ZipTests/kYkLkPf.gif
0 → 100644
View file @
c29f08bc
759 KB
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