Finish loading a file verification packet
| 651 | |
| 652 | // Finish loading a file verification packet |
| 653 | bool Par2Repairer::LoadVerificationPacket(DiskFile *diskfile, u64 offset, PACKET_HEADER &header) |
| 654 | { |
| 655 | VerificationPacket *packet = new VerificationPacket; |
| 656 | |
| 657 | // Load the packet from disk |
| 658 | if (!packet->Load(diskfile, offset, header)) |
| 659 | { |
| 660 | delete packet; |
| 661 | return false; |
| 662 | } |
| 663 | |
| 664 | // What is the fileid |
| 665 | const MD5Hash &fileid = packet->FileId(); |
| 666 | |
| 667 | // Look up the fileid in the source file map for an existing source file entry |
| 668 | std::map<MD5Hash, Par2RepairerSourceFile*>::iterator sfmi = sourcefilemap.find(fileid); |
| 669 | Par2RepairerSourceFile *sourcefile = (sfmi == sourcefilemap.end()) ? 0 :sfmi->second; |
| 670 | |
| 671 | // Was there an existing source file |
| 672 | if (sourcefile) |
| 673 | { |
| 674 | // Does the source file already have a verification packet |
| 675 | if (sourcefile->GetVerificationPacket()) |
| 676 | { |
| 677 | // Yes. We don't need another copy. |
| 678 | delete packet; |
| 679 | return false; |
| 680 | } |
| 681 | else |
| 682 | { |
| 683 | // No. Store the packet in the source file |
| 684 | sourcefile->SetVerificationPacket(packet); |
| 685 | |
| 686 | return true; |
| 687 | } |
| 688 | } |
| 689 | else |
| 690 | { |
| 691 | // Create a new source file for the packet |
| 692 | sourcefile = new Par2RepairerSourceFile(NULL, packet); |
| 693 | |
| 694 | // Record the source file in the source file map |
| 695 | sourcefilemap.insert(std::pair<MD5Hash, Par2RepairerSourceFile*>(fileid, sourcefile)); |
| 696 | |
| 697 | return true; |
| 698 | } |
| 699 | } |
| 700 | |
| 701 | // Finish loading the main packet |
| 702 | bool Par2Repairer::LoadMainPacket(DiskFile *diskfile, u64 offset, PACKET_HEADER &header) |
nothing calls this directly
no test coverage detected