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
0778cf73
Commit
0778cf73
authored
8 years ago
by
Roy Marmelstein
Committed by
GitHub
8 years ago
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #73 from marmelroy/bugfix/permissionsissue#72
Bugfix/permissionsissue#72
parents
6f3b6b44
26aa500b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
0 deletions
+38
-0
Zip.xcodeproj/project.pbxproj
Zip.xcodeproj/project.pbxproj
+4
-0
Zip/Zip.swift
Zip/Zip.swift
+11
-0
ZipTests/ZipTests.swift
ZipTests/ZipTests.swift
+23
-0
ZipTests/permissions.zip
ZipTests/permissions.zip
+0
-0
No files found.
Zip.xcodeproj/project.pbxproj
View file @
0778cf73
...
...
@@ -7,6 +7,7 @@
objects
=
{
/* Begin PBXBuildFile section */
303B4F6E1E4CBE5000DC1633
/* permissions.zip in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
303B4F6D1E4CBE5000DC1633
/* permissions.zip */
;
};
342545901CE525B200336074
/* Zip.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
347E3AD71C1E04C900A11FD3
/* Zip.swift */
;
};
342545921CE525B200336074
/* unzip.c in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
342FC0EB1C5044DC0023A3C3
/* unzip.c */
;
};
342545941CE525B200336074
/* QuickZip.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3443A3F51C4AB8A3004AD173
/* QuickZip.swift */
;
};
...
...
@@ -69,6 +70,7 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
303B4F6D1E4CBE5000DC1633
/* permissions.zip */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
archive.zip
;
path
=
permissions.zip
;
sourceTree
=
"<group>"
;
};
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>"
;
};
342FC0E81C5044DC0023A3C3
/* ioapi.c */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.c
;
path
=
ioapi.c
;
sourceTree
=
"<group>"
;
};
...
...
@@ -194,6 +196,7 @@
347E3A821C1DFFB500A11FD3
/* ZipTests */
=
{
isa
=
PBXGroup
;
children
=
(
303B4F6D1E4CBE5000DC1633
/* permissions.zip */
,
34940A221C58876200D41574
/* 3crBXeO.gif */
,
34940A231C58876200D41574
/* kYkLkPf.gif */
,
3443A3FC1C4AD199004AD173
/* bb8.zip */
,
...
...
@@ -415,6 +418,7 @@
isa
=
PBXResourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
303B4F6E1E4CBE5000DC1633
/* permissions.zip in Resources */
,
34940A251C58876200D41574
/* kYkLkPf.gif in Resources */
,
3443A3FD1C4AD199004AD173
/* bb8.zip in Resources */
,
34940A241C58876200D41574
/* 3crBXeO.gif in Resources */
,
...
...
This diff is collapsed.
Click to expand it.
Zip/Zip.swift
View file @
0778cf73
...
...
@@ -145,6 +145,7 @@ public class Zip {
unzGetCurrentFileInfo64
(
zip
,
&
fileInfo
,
fileName
,
UInt
(
fileNameSize
),
nil
,
0
,
nil
,
0
)
fileName
[
Int
(
fileInfo
.
size_filename
)]
=
0
var
pathString
=
String
(
cString
:
fileName
)
guard
pathString
.
characters
.
count
>
0
else
{
...
...
@@ -190,11 +191,21 @@ public class Zip {
break
}
}
fclose
(
filePointer
)
crc_ret
=
unzCloseCurrentFile
(
zip
)
if
crc_ret
==
UNZ_CRCERROR
{
throw
ZipError
.
unzipFail
}
//Set file permissions from current fileInfo
let
permissions
=
(
fileInfo
.
external_fa
>>
16
)
&
0x1FF
do
{
try
fileManager
.
setAttributes
([
.
posixPermissions
:
permissions
],
ofItemAtPath
:
fullPath
)
}
catch
let
error
{
print
(
"Failed to set permissions to file
\(
fullPath
)
"
)
}
ret
=
unzGoToNextFile
(
zip
)
// Update progress handler
...
...
This diff is collapsed.
Click to expand it.
ZipTests/ZipTests.swift
View file @
0778cf73
...
...
@@ -217,6 +217,29 @@ class ZipTests: XCTestCase {
}
}
func
testUnzipPermissions
()
{
do
{
let
permissionsURL
=
Bundle
(
for
:
ZipTests
.
self
)
.
url
(
forResource
:
"permissions"
,
withExtension
:
"zip"
)
!
let
unzipDestination
=
try
Zip
.
quickUnzipFile
(
permissionsURL
)
let
fileManager
=
FileManager
.
default
let
permission777
=
unzipDestination
.
appendingPathComponent
(
"permission_777"
)
.
appendingPathExtension
(
"txt"
)
let
permission600
=
unzipDestination
.
appendingPathComponent
(
"permission_600"
)
.
appendingPathExtension
(
"txt"
)
let
permission604
=
unzipDestination
.
appendingPathComponent
(
"permission_604"
)
.
appendingPathExtension
(
"txt"
)
do
{
let
attributes777
=
try
fileManager
.
attributesOfItem
(
atPath
:
permission777
.
path
)
let
attributes600
=
try
fileManager
.
attributesOfItem
(
atPath
:
permission600
.
path
)
let
attributes604
=
try
fileManager
.
attributesOfItem
(
atPath
:
permission604
.
path
)
XCTAssertEqual
(
attributes777
[
.
posixPermissions
]
as?
Int
,
0o777
)
XCTAssertEqual
(
attributes600
[
.
posixPermissions
]
as?
Int
,
0o600
)
XCTAssertEqual
(
attributes604
[
.
posixPermissions
]
as?
Int
,
0o604
)
}
catch
{
XCTFail
(
"Failed to get file attributes
\(
error
)
"
)
}
}
catch
{
XCTFail
(
"Failed extract permissions.zip"
)
}
}
func
testQuickUnzipSubDir
()
{
do
{
...
...
This diff is collapsed.
Click to expand it.
ZipTests/permissions.zip
0 → 100644
View file @
0778cf73
File added
This diff is collapsed.
Click to expand it.
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