Finish loading a file description packet
| 603 | |
| 604 | // Finish loading a file description packet |
| 605 | bool Par2Repairer::LoadDescriptionPacket(DiskFile *diskfile, u64 offset, PACKET_HEADER &header) |
| 606 | { |
| 607 | DescriptionPacket *packet = new DescriptionPacket; |
| 608 | |
| 609 | // Load the packet from disk |
| 610 | if (!packet->Load(diskfile, offset, header)) |
| 611 | { |
| 612 | delete packet; |
| 613 | return false; |
| 614 | } |
| 615 | |
| 616 | // What is the fileid |
| 617 | const MD5Hash &fileid = packet->FileId(); |
| 618 | |
| 619 | // Look up the fileid in the source file map for an existing source file entry |
| 620 | std::map<MD5Hash, Par2RepairerSourceFile*>::iterator sfmi = sourcefilemap.find(fileid); |
| 621 | Par2RepairerSourceFile *sourcefile = (sfmi == sourcefilemap.end()) ? 0 :sfmi->second; |
| 622 | |
| 623 | // Was there an existing source file |
| 624 | if (sourcefile) |
| 625 | { |
| 626 | // Does the source file already have a description packet |
| 627 | if (sourcefile->GetDescriptionPacket()) |
| 628 | { |
| 629 | // Yes. We don't need another copy |
| 630 | delete packet; |
| 631 | return false; |
| 632 | } |
| 633 | else |
| 634 | { |
| 635 | // No. Store the packet in the source file |
| 636 | sourcefile->SetDescriptionPacket(packet); |
| 637 | return true; |
| 638 | } |
| 639 | } |
| 640 | else |
| 641 | { |
| 642 | // Create a new source file for the packet |
| 643 | sourcefile = new Par2RepairerSourceFile(packet, NULL); |
| 644 | |
| 645 | // Record the source file in the source file map |
| 646 | sourcefilemap.insert(std::pair<MD5Hash, Par2RepairerSourceFile*>(fileid, sourcefile)); |
| 647 | |
| 648 | return true; |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | // Finish loading a file verification packet |
| 653 | bool Par2Repairer::LoadVerificationPacket(DiskFile *diskfile, u64 offset, PACKET_HEADER &header) |
nothing calls this directly
no test coverage detected