| 491 | ***************************************************************************/ |
| 492 | |
| 493 | size_t SzExtractFile(int i, unsigned char *buffer) |
| 494 | { |
| 495 | // prepare some variables |
| 496 | SzBlockIndex = 0xFFFFFFFF; |
| 497 | SzOffset = 0; |
| 498 | |
| 499 | // Unzip the file |
| 500 | |
| 501 | SzRes = SzExtract2( |
| 502 | &SzArchiveStream.InStream, |
| 503 | &SzDb, |
| 504 | i, // index of file |
| 505 | &SzBlockIndex, // index of solid block |
| 506 | &buffer, |
| 507 | &SzBufferSize, |
| 508 | &SzOffset, // offset of stream for required file in *outBuffer |
| 509 | &SzOutSizeProcessed, // size of file in *outBuffer |
| 510 | &SzAllocImp, |
| 511 | &SzAllocTempImp); |
| 512 | |
| 513 | // close 7Zip archive and free memory |
| 514 | SzClose(); |
| 515 | |
| 516 | CancelAction(); |
| 517 | |
| 518 | // check for errors |
| 519 | if(SzRes != SZ_OK) |
| 520 | { |
| 521 | // display error message |
| 522 | SzDisplayError(SzRes); |
| 523 | return 0; |
| 524 | } |
| 525 | else |
| 526 | { |
| 527 | return SzOutSizeProcessed; |
| 528 | } |
| 529 | } |
no test coverage detected