Overview
Comment: | OFZIP: Handle all exceptions |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8b7fd2fdd8ac8234cfba120906bd453c |
User & Date: | js on 2014-09-10 10:51:54 |
Other Links: | manifest | tags |
Context
2014-09-10
| ||
14:05 | Fix -[OFBigDataArray initWithContentsOfURL:] check-in: dc83295447 user: js tags: trunk | |
10:51 | OFZIP: Handle all exceptions check-in: 8b7fd2fdd8 user: js tags: trunk | |
2014-09-08
| ||
01:14 | Add utils/ofhash check-in: 2c629663ea user: js tags: trunk | |
Changes
Modified utils/ofzip/OFZIP.m from [25402b5587] to [d5a79eecab].
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #import "OFStdIOStream.h" #import "OFZIPArchive.h" #import "OFZIPArchiveEntry.h" #import "OFCreateDirectoryFailedException.h" #import "OFInvalidFormatException.h" #import "OFOpenFileFailedException.h" #import "autorelease.h" #import "macros.h" #define BUFFER_SIZE 4096 #ifndef S_IRWXG | > > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #import "OFStdIOStream.h" #import "OFZIPArchive.h" #import "OFZIPArchiveEntry.h" #import "OFCreateDirectoryFailedException.h" #import "OFInvalidFormatException.h" #import "OFOpenFileFailedException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #import "autorelease.h" #import "macros.h" #define BUFFER_SIZE 4096 #ifndef S_IRWXG |
︙ | ︙ | |||
209 210 211 212 213 214 215 216 217 218 219 220 221 222 | OFZIPArchive *archive = nil; @try { archive = [OFZIPArchive archiveWithPath: path]; } @catch (OFOpenFileFailedException *e) { [of_stderr writeFormat: @"Failed to open file %@: %s\n", [e path], strerror([e errNo])]; [OFApplication terminateWithStatus: 1]; } @catch (OFInvalidFormatException *e) { [of_stderr writeFormat: @"File %@ is not a valid archive!\n", path]; [OFApplication terminateWithStatus: 1]; } | > > > > | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | OFZIPArchive *archive = nil; @try { archive = [OFZIPArchive archiveWithPath: path]; } @catch (OFOpenFileFailedException *e) { [of_stderr writeFormat: @"Failed to open file %@: %s\n", [e path], strerror([e errNo])]; [OFApplication terminateWithStatus: 1]; } @catch (OFReadFailedException *e) { [of_stderr writeFormat: @"Failed to read file %@: %s\n", path, strerror([e errNo])]; [OFApplication terminateWithStatus: 1]; } @catch (OFInvalidFormatException *e) { [of_stderr writeFormat: @"File %@ is not a valid archive!\n", path]; [OFApplication terminateWithStatus: 1]; } |
︙ | ︙ | |||
385 386 387 388 389 390 391 | stream = [archive streamForReadingFile: fileName]; output = [OFFile fileWithPath: outFileName mode: @"wb"]; setPermissions(outFileName, entry); while (![stream isAtEndOfStream]) { | > > > | | > > > > > > > > > > | | > > > > > > > > > | 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | stream = [archive streamForReadingFile: fileName]; output = [OFFile fileWithPath: outFileName mode: @"wb"]; setPermissions(outFileName, entry); while (![stream isAtEndOfStream]) { size_t length; @try { length = [stream readIntoBuffer: buffer length: BUFFER_SIZE]; } @catch (OFReadFailedException *e) { [of_stderr writeFormat: @"\rFailed to read file %@: %s\n", fileName, strerror([e errNo])]; _exitStatus = 1; goto outer_loop_end; } @try { [output writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { [of_stderr writeFormat: @"\rFailed to write file %@: %s\n", fileName, strerror([e errNo])]; _exitStatus = 1; goto outer_loop_end; } written += length; newPercent = (written == size ? 100 : (int_fast8_t)(written * 100 / size)); if (_outputLevel >= 0 && percent != newPercent) { percent = newPercent; [of_stdout writeFormat: @"\rExtracting %@... %3u%%", fileName, percent]; } } if (_outputLevel >= 0) [of_stdout writeFormat: @"\rExtracting %@... done\n", fileName]; outer_loop_end: objc_autoreleasePoolPop(pool); } if ([missing count] > 0) { OFString *file; enumerator = [missing objectEnumerator]; |
︙ | ︙ |