Finish loading a recovery packet
| 574 | |
| 575 | // Finish loading a recovery packet |
| 576 | bool Par2Repairer::LoadRecoveryPacket(DiskFile *diskfile, u64 offset, PACKET_HEADER &header) |
| 577 | { |
| 578 | RecoveryPacket *packet = new RecoveryPacket; |
| 579 | |
| 580 | // Load the packet from disk |
| 581 | if (!packet->Load(diskfile, offset, header)) |
| 582 | { |
| 583 | delete packet; |
| 584 | return false; |
| 585 | } |
| 586 | |
| 587 | // What is the exponent value of this recovery packet |
| 588 | u32 exponent = packet->Exponent(); |
| 589 | |
| 590 | // Try to insert the new packet into the recovery packet map |
| 591 | std::pair<std::map<u32,RecoveryPacket*>::const_iterator, bool> location = recoverypacketmap.insert(std::pair<u32,RecoveryPacket*>(exponent, packet)); |
| 592 | |
| 593 | // Did the insert fail |
| 594 | if (!location.second) |
| 595 | { |
| 596 | // The packet must be a duplicate of one we already have |
| 597 | delete packet; |
| 598 | return false; |
| 599 | } |
| 600 | |
| 601 | return true; |
| 602 | } |
| 603 | |
| 604 | // Finish loading a file description packet |
| 605 | bool Par2Repairer::LoadDescriptionPacket(DiskFile *diskfile, u64 offset, PACKET_HEADER &header) |