| 531 | } |
| 532 | |
| 533 | bool ZipArchive::copyFileToNewZip(CentralDir *cdir, Stream *newZipStream) |
| 534 | { |
| 535 | // [tom, 1/24/2007] Using the stored compressor allows us to copy the raw |
| 536 | // data regardless of compression method without having to re-compress it. |
| 537 | Compressor *comp = Compressor::findCompressor(Stored); |
| 538 | if(comp == NULL) |
| 539 | return false; |
| 540 | |
| 541 | if(! mStream->setPosition(cdir->mLocalHeadOffset)) |
| 542 | return false; |
| 543 | |
| 544 | // Copy file header |
| 545 | // FIXME [tom, 1/24/2007] This will currently not copy the extra fields |
| 546 | FileHeader fh; |
| 547 | if(! fh.read(mStream)) |
| 548 | return false; |
| 549 | |
| 550 | cdir->mLocalHeadOffset = newZipStream->getPosition(); |
| 551 | |
| 552 | if(! fh.write(newZipStream)) |
| 553 | return false; |
| 554 | |
| 555 | // Copy file data |
| 556 | Stream *readS = comp->createReadStream(cdir, mStream); |
| 557 | if(readS == NULL) |
| 558 | return false; |
| 559 | |
| 560 | bool ret = newZipStream->copyFrom(readS); |
| 561 | |
| 562 | // [tom, 1/24/2007] closeFile() just frees the relevant filters and |
| 563 | // thus it is safe to call from here. |
| 564 | closeFile(readS); |
| 565 | |
| 566 | return ret; |
| 567 | } |
| 568 | |
| 569 | //----------------------------------------------------------------------------- |
| 570 | // Public Methods |
nothing calls this directly
no test coverage detected