File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -180,12 +180,17 @@ public class Zip {
180
180
unzCloseCurrentFile ( zip)
181
181
ret = unzGoToNextFile ( zip)
182
182
}
183
+
184
+ var writeBytes : UInt64 = 0
183
185
var filePointer : UnsafeMutablePointer < FILE > ?
184
186
filePointer = fopen ( fullPath, " wb " )
185
187
while filePointer != nil {
186
188
let readBytes = unzReadCurrentFile ( zip, & buffer, bufferSize)
187
189
if readBytes > 0 {
188
- fwrite ( buffer, Int ( readBytes) , 1 , filePointer)
190
+ guard fwrite ( buffer, Int ( readBytes) , 1 , filePointer) == 1 else {
191
+ throw ZipError . unzipFail
192
+ }
193
+ writeBytes += UInt64 ( readBytes)
189
194
}
190
195
else {
191
196
break
@@ -197,6 +202,9 @@ public class Zip {
197
202
if crc_ret == UNZ_CRCERROR {
198
203
throw ZipError . unzipFail
199
204
}
205
+ guard writeBytes == fileInfo. uncompressed_size else {
206
+ throw ZipError . unzipFail
207
+ }
200
208
201
209
//Set file permissions from current fileInfo
202
210
if fileInfo. external_fa != 0 {
You can’t perform that action at this time.
0 commit comments