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
643317ed
Commit
643317ed
authored
Mar 15, 2017
by
Roy Marmelstein
Committed by
GitHub
Mar 15, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #75 from marmelroy/bugfix/issue74
+Fix for issue #74
parents
915876fa
af563e5d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
5 deletions
+32
-5
Zip.xcodeproj/project.pbxproj
Zip.xcodeproj/project.pbxproj
+4
-0
Zip/Zip.swift
Zip/Zip.swift
+10
-5
ZipTests/ZipTests.swift
ZipTests/ZipTests.swift
+18
-0
ZipTests/unsupported_permissions.zip
ZipTests/unsupported_permissions.zip
+0
-0
No files found.
Zip.xcodeproj/project.pbxproj
View file @
643317ed
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
/* Begin PBXBuildFile section */
303B4F6E1E4CBE5000DC1633
/* permissions.zip in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
303B4F6D1E4CBE5000DC1633
/* permissions.zip */
;
};
303B4F6E1E4CBE5000DC1633
/* permissions.zip in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
303B4F6D1E4CBE5000DC1633
/* permissions.zip */
;
};
305237181E64595700CA46D1
/* unsupported_permissions.zip in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
305237171E64595700CA46D1
/* unsupported_permissions.zip */
;
};
342545901CE525B200336074
/* Zip.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
347E3AD71C1E04C900A11FD3
/* Zip.swift */
;
};
342545901CE525B200336074
/* Zip.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
347E3AD71C1E04C900A11FD3
/* Zip.swift */
;
};
342545921CE525B200336074
/* unzip.c in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
342FC0EB1C5044DC0023A3C3
/* unzip.c */
;
};
342545921CE525B200336074
/* unzip.c in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
342FC0EB1C5044DC0023A3C3
/* unzip.c */
;
};
342545941CE525B200336074
/* QuickZip.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3443A3F51C4AB8A3004AD173
/* QuickZip.swift */
;
};
342545941CE525B200336074
/* QuickZip.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3443A3F51C4AB8A3004AD173
/* QuickZip.swift */
;
};
...
@@ -71,6 +72,7 @@
...
@@ -71,6 +72,7 @@
/* Begin PBXFileReference section */
/* Begin PBXFileReference section */
303B4F6D1E4CBE5000DC1633
/* permissions.zip */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
archive.zip
;
path
=
permissions.zip
;
sourceTree
=
"<group>"
;
};
303B4F6D1E4CBE5000DC1633
/* permissions.zip */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
archive.zip
;
path
=
permissions.zip
;
sourceTree
=
"<group>"
;
};
305237171E64595700CA46D1
/* unsupported_permissions.zip */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
archive.zip
;
path
=
unsupported_permissions.zip
;
sourceTree
=
"<group>"
;
};
342545B51CE525B200336074
/* Zip.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
Zip.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
342545B51CE525B200336074
/* Zip.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
Zip.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
342FC0E71C5044DC0023A3C3
/* crypt.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
crypt.h
;
sourceTree
=
"<group>"
;
};
342FC0E71C5044DC0023A3C3
/* crypt.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
crypt.h
;
sourceTree
=
"<group>"
;
};
342FC0E81C5044DC0023A3C3
/* ioapi.c */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.c
;
path
=
ioapi.c
;
sourceTree
=
"<group>"
;
};
342FC0E81C5044DC0023A3C3
/* ioapi.c */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.c
;
path
=
ioapi.c
;
sourceTree
=
"<group>"
;
};
...
@@ -196,6 +198,7 @@
...
@@ -196,6 +198,7 @@
347E3A821C1DFFB500A11FD3
/* ZipTests */
=
{
347E3A821C1DFFB500A11FD3
/* ZipTests */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
305237171E64595700CA46D1
/* unsupported_permissions.zip */
,
303B4F6D1E4CBE5000DC1633
/* permissions.zip */
,
303B4F6D1E4CBE5000DC1633
/* permissions.zip */
,
34940A221C58876200D41574
/* 3crBXeO.gif */
,
34940A221C58876200D41574
/* 3crBXeO.gif */
,
34940A231C58876200D41574
/* kYkLkPf.gif */
,
34940A231C58876200D41574
/* kYkLkPf.gif */
,
...
@@ -418,6 +421,7 @@
...
@@ -418,6 +421,7 @@
isa
=
PBXResourcesBuildPhase
;
isa
=
PBXResourcesBuildPhase
;
buildActionMask
=
2147483647
;
buildActionMask
=
2147483647
;
files
=
(
files
=
(
305237181E64595700CA46D1
/* unsupported_permissions.zip in Resources */
,
303B4F6E1E4CBE5000DC1633
/* permissions.zip in Resources */
,
303B4F6E1E4CBE5000DC1633
/* permissions.zip in Resources */
,
34940A251C58876200D41574
/* kYkLkPf.gif in Resources */
,
34940A251C58876200D41574
/* kYkLkPf.gif in Resources */
,
3443A3FD1C4AD199004AD173
/* bb8.zip in Resources */
,
3443A3FD1C4AD199004AD173
/* bb8.zip in Resources */
,
...
...
Zip/Zip.swift
View file @
643317ed
...
@@ -199,11 +199,16 @@ public class Zip {
...
@@ -199,11 +199,16 @@ public class Zip {
}
}
//Set file permissions from current fileInfo
//Set file permissions from current fileInfo
if
fileInfo
.
external_fa
!=
0
{
let
permissions
=
(
fileInfo
.
external_fa
>>
16
)
&
0x1FF
let
permissions
=
(
fileInfo
.
external_fa
>>
16
)
&
0x1FF
//We will devifne a valid permission range between Owner read only to full access
if
permissions
>=
0o400
&&
permissions
<=
0o777
{
do
{
do
{
try
fileManager
.
setAttributes
([
.
posixPermissions
:
permissions
],
ofItemAtPath
:
fullPath
)
try
fileManager
.
setAttributes
([
.
posixPermissions
:
permissions
],
ofItemAtPath
:
fullPath
)
}
catch
let
error
{
}
catch
{
print
(
"Failed to set permissions to file
\(
fullPath
)
"
)
print
(
"Failed to set permissions to file
\(
fullPath
)
, error:
\(
error
)
"
)
}
}
}
}
ret
=
unzGoToNextFile
(
zip
)
ret
=
unzGoToNextFile
(
zip
)
...
...
ZipTests/ZipTests.swift
View file @
643317ed
...
@@ -217,6 +217,24 @@ class ZipTests: XCTestCase {
...
@@ -217,6 +217,24 @@ class ZipTests: XCTestCase {
}
}
}
}
func
testUnzipWithUnsupportedPermissions
()
{
do
{
let
permissionsURL
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"unsupported_permissions"
,
withExtension
:
"zip"
)
!
let
unzipDestination
=
try
Zip
.
quickUnzipFile
(
permissionsURL
)
print
(
unzipDestination
)
let
fileManager
=
FileManager
.
default
let
permission644
=
unzipDestination
.
appendingPathComponent
(
"unsupported_permission"
)
.
appendingPathExtension
(
"txt"
)
do
{
let
attributes644
=
try
fileManager
.
attributesOfItem
(
atPath
:
permission644
.
path
)
XCTAssertEqual
(
attributes644
[
.
posixPermissions
]
as?
Int
,
0o644
)
}
catch
{
XCTFail
(
"Failed to get file attributes
\(
error
)
"
)
}
}
catch
{
XCTFail
(
"Failed extract unsupported_permissions.zip"
)
}
}
func
testUnzipPermissions
()
{
func
testUnzipPermissions
()
{
do
{
do
{
let
permissionsURL
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"permissions"
,
withExtension
:
"zip"
)
!
let
permissionsURL
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"permissions"
,
withExtension
:
"zip"
)
!
...
...
ZipTests/unsupported_permissions.zip
0 → 100644
View file @
643317ed
File added
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