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
ec48965f
Commit
ec48965f
authored
Feb 22, 2019
by
Keanu Pang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HA-1053
Workaround fix for memory allocation in unzip process
parent
000fb6b0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
77 deletions
+78
-77
.swift-version
.swift-version
+1
-1
Zip/Zip.swift
Zip/Zip.swift
+77
-76
No files found.
.swift-version
View file @
ec48965f
4.
1
4.
2
Zip/Zip.swift
View file @
ec48965f
...
...
@@ -153,12 +153,13 @@ public class Zip {
throw
ZipError
.
unzipFail
}
currentPosition
+=
Double
(
fileInfo
.
compressed_size
)
let
fileNameSize
=
Int
(
fileInfo
.
size_filename
)
+
1
fileInfo
.
size_filename
=
10240
let
fileNameSize
=
10240
// Int(fileInfo.size_filename) + 1
//let fileName = UnsafeMutablePointer<CChar>(allocatingCapacity: fileNameSize)
let
fileName
=
UnsafeMutablePointer
<
CChar
>.
allocate
(
capacity
:
fileNameSize
)
unzGetCurrentFileInfo64
(
zip
,
&
fileInfo
,
fileName
,
UInt
(
fileNameSize
),
nil
,
0
,
nil
,
0
)
fileName
[
Int
(
fileInfo
.
size_filename
)]
=
0
//
fileName[Int(fileInfo.size_filename)] = 0
var
pathString
=
String
(
cString
:
fileName
)
...
...
@@ -166,11 +167,11 @@ public class Zip {
throw
ZipError
.
unzipFail
}
var
isDirectory
=
false
let
fileInfoSizeFileName
=
Int
(
fileInfo
.
size_filename
-
1
)
if
(
fileName
[
fileInfoSizeFileName
]
==
"/"
.
cString
(
using
:
String
.
Encoding
.
utf8
)?
.
first
||
fileName
[
fileInfoSizeFileName
]
==
"
\\
"
.
cString
(
using
:
String
.
Encoding
.
utf8
)?
.
first
)
{
isDirectory
=
true
;
}
//
var isDirectory = false
//
let fileInfoSizeFileName = Int(fileInfo.size_filename-1)
//
if (fileName[fileInfoSizeFileName] == "/".cString(using: String.Encoding.utf8)?.first || fileName[fileInfoSizeFileName] == "\\".cString(using: String.Encoding.utf8)?.first) {
//
isDirectory = true;
//
}
free
(
fileName
)
if
pathString
.
rangeOfCharacter
(
from
:
CharacterSet
(
charactersIn
:
"/
\\
"
))
!=
nil
{
pathString
=
pathString
.
replacingOccurrences
(
of
:
"
\\
"
,
with
:
"/"
)
...
...
@@ -184,15 +185,15 @@ public class Zip {
FileAttributeKey
.
modificationDate
:
creationDate
]
do
{
if
isDirectory
{
try
fileManager
.
createDirectory
(
atPath
:
fullPath
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
}
else
{
//
if isDirectory {
//
try fileManager.createDirectory(atPath: fullPath, withIntermediateDirectories: true, attributes: directoryAttributes)
//
}
//
else {
let
parentDirectory
=
(
fullPath
as
NSString
)
.
deletingLastPathComponent
try
fileManager
.
createDirectory
(
atPath
:
parentDirectory
,
withIntermediateDirectories
:
true
,
attributes
:
directoryAttributes
)
}
//
}
}
catch
{}
if
fileManager
.
fileExists
(
atPath
:
fullPath
)
&&
!
isDirectory
&&
!
overwrite
{
if
fileManager
.
fileExists
(
atPath
:
fullPath
)
&&
!
overwrite
{
// !
isDirectory && !overwrite {
unzCloseCurrentFile
(
zip
)
ret
=
unzGoToNextFile
(
zip
)
}
...
...
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