Changeset 39049 in vbox
- Timestamp:
- Oct 20, 2011 9:39:22 AM (13 years ago)
- Location:
- trunk/src/VBox/Runtime/common/zip
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/zip/gzipvfs.cpp
r39043 r39049 186 186 case Z_BUF_ERROR: 187 187 /* This isn't fatal. */ 188 return VINF_SUCCESS; 189 190 case Z_ERRNO: 188 return VINF_SUCCESS; /** @todo The code in zip.cpp treats Z_BUF_ERROR as fatal... */ 189 191 190 case Z_STREAM_ERROR: 191 pThis->fFatalError = true; 192 return VERR_ZIP_CORRUPTED; 193 192 194 case Z_DATA_ERROR: 195 pThis->fFatalError = true; 196 return pThis->fDecompress ? VERR_ZIP_CORRUPTED : VERR_ZIP_ERROR; 197 193 198 case Z_MEM_ERROR: 199 pThis->fFatalError = true; 200 return VERR_ZIP_NO_MEMORY; 201 194 202 case Z_VERSION_ERROR: 195 203 pThis->fFatalError = true; 196 switch (rc) 197 { 198 case Z_ERRNO: return VERR_INTERNAL_ERROR_5; 199 case Z_STREAM_ERROR: return VERR_INTERNAL_ERROR_3; 200 case Z_DATA_ERROR: return VERR_ZIP_ERROR; 201 case Z_MEM_ERROR: return VERR_ZIP_NO_MEMORY; 202 case Z_VERSION_ERROR: return VERR_ZIP_UNSUPPORTED_VERSION; 203 } 204 /* not reached */ 205 204 return VERR_ZIP_UNSUPPORTED_VERSION; 205 206 case Z_ERRNO: /* We shouldn't see this status! */ 206 207 default: 208 AssertMsgFailed(("%d\n", rc)); 207 209 if (rc >= 0) 208 210 return VINF_SUCCESS; -
trunk/src/VBox/Runtime/common/zip/zip.cpp
r33982 r39049 420 420 * Convert from zlib errno to iprt status code. 421 421 * @returns iprt status code. 422 * @param rc Zlib error code.423 * /424 static int zipErrConvertFromZlib(int rc) 425 { 426 /** @todo proper zlib error conversion. */ 422 * @param rc Zlib error code. 423 * @param fCompressing Set if we're compressing, clear if decompressing. 424 */ 425 static int zipErrConvertFromZlib(int rc, bool fCompressing) 426 { 427 427 switch (rc) 428 428 { 429 case Z_ERRNO: 430 return RTErrConvertFromErrno(errno); 429 case Z_OK: 430 return VINF_SUCCESS; 431 431 432 case Z_STREAM_ERROR: 433 return VERR_ZIP_CORRUPTED; 434 432 435 case Z_DATA_ERROR: 436 return fCompressing ? VERR_ZIP_ERROR : VERR_ZIP_CORRUPTED; 437 433 438 case Z_MEM_ERROR: 439 return VERR_ZIP_NO_MEMORY; 440 434 441 case Z_BUF_ERROR: 442 return VERR_ZIP_ERROR; 443 435 444 case Z_VERSION_ERROR: 436 return VERR_GENERAL_FAILURE; 445 return VERR_ZIP_UNSUPPORTED_VERSION; 446 447 case Z_ERRNO: /* We shouldn't see this status! */ 437 448 default: 449 AssertMsgFailed(("%d\n", rc)); 438 450 if (rc >= 0) 439 451 return VINF_SUCCESS; 440 return VERR_ GENERAL_FAILURE;452 return VERR_ZIP_ERROR; 441 453 } 442 454 } … … 469 481 int rc = deflate(&pZip->u.Zlib, Z_NO_FLUSH); 470 482 if (rc != Z_OK) 471 return zipErrConvertFromZlib(rc );483 return zipErrConvertFromZlib(rc, true /*fCompressing*/); 472 484 } 473 485 return VINF_SUCCESS; … … 502 514 rc = deflate(&pZip->u.Zlib, Z_FINISH); 503 515 if (rc != Z_OK && rc != Z_STREAM_END) 504 return zipErrConvertFromZlib(rc );516 return zipErrConvertFromZlib(rc, true /*fCompressing*/); 505 517 } 506 518 return VINF_SUCCESS; … … 518 530 int rc = deflateEnd(&pZip->u.Zlib); 519 531 if (rc != Z_OK) 520 rc = zipErrConvertFromZlib(rc );532 rc = zipErrConvertFromZlib(rc, true /*fCompressing*/); 521 533 return rc; 522 534 } … … 550 562 551 563 int rc = deflateInit(&pZip->u.Zlib, enmLevel); 552 return rc >= 0 ? rc = VINF_SUCCESS : zipErrConvertFromZlib(rc );564 return rc >= 0 ? rc = VINF_SUCCESS : zipErrConvertFromZlib(rc, true /*fCompressing*/); 553 565 } 554 566 … … 595 607 } 596 608 if (rc != Z_OK) 597 return zipErrConvertFromZlib(rc );609 return zipErrConvertFromZlib(rc, false /*fCompressing*/); 598 610 } 599 611 return VINF_SUCCESS; … … 611 623 int rc = inflateEnd(&pZip->u.Zlib); 612 624 if (rc != Z_OK) 613 rc = zipErrConvertFromZlib(rc );625 rc = zipErrConvertFromZlib(rc, false /*fCompressing*/); 614 626 return rc; 615 627 } … … 630 642 631 643 int rc = inflateInit(&pZip->u.Zlib); 632 return rc >= 0 ? VINF_SUCCESS : zipErrConvertFromZlib(rc );644 return rc >= 0 ? VINF_SUCCESS : zipErrConvertFromZlib(rc, false /*fCompressing*/); 633 645 } 634 646
Note:
See TracChangeset
for help on using the changeset viewer.