1 // This file is part of par2cmdline (a PAR 2.0 compatible file verification and 2 // repair tool). See http://parchive.sourceforge.net for details of PAR 2.0. 3 // 4 // Copyright (c) 2003 Peter Brian Clements 5 // 6 // par2cmdline is free software; you can redistribute it and/or modify 7 // it under the terms of the GNU General Public License as published by 8 // the Free Software Foundation; either version 2 of the License, or 9 // (at your option) any later version. 10 // 11 // par2cmdline is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software 18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 19 20 #ifndef __PAR2REPAIRERSOURCEFILE_H__ 21 #define __PAR2REPAIRERSOURCEFILE_H__ 22 23 enum MatchType 24 { 25 eNoMatch = 0, 26 ePartialMatch, 27 eFullMatch 28 }; 29 30 // The Par2RepairerSourceFile object is used during verification and repair 31 // to record details about a particular source file and the data blocks 32 // for that file. 33 34 class Par2RepairerSourceFile 35 { 36 public: 37 // Construct the object and set the description and verification packets 38 Par2RepairerSourceFile(DescriptionPacket *descriptionpacket, 39 VerificationPacket *verificationpacket); 40 ~Par2RepairerSourceFile(void); 41 42 // Get/Set the description packet GetDescriptionPacket(void)43 DescriptionPacket* GetDescriptionPacket(void) const {return descriptionpacket;} 44 void SetDescriptionPacket(DescriptionPacket *descriptionpacket); 45 46 // Get/Set the verification packet GetVerificationPacket(void)47 VerificationPacket* GetVerificationPacket(void) const {return verificationpacket;} 48 void SetVerificationPacket(VerificationPacket *verificationpacket); 49 50 // Record the details as to which data blocks belong to this source 51 // file and set the length of each allocated block correctly. 52 void SetBlocks(u32 _blocknumber, 53 u32 _blockcount, 54 vector<DataBlock>::iterator _sourceblocks, 55 vector<DataBlock>::iterator _targetblocks, 56 u64 blocksize); 57 58 // Determine the block count from the file size and block size. 59 void SetBlockCount(u64 blocksize); 60 61 // Set/Get which DiskFile will contain the final repaired version of the file 62 void SetTargetFile(DiskFile *diskfile); 63 DiskFile* GetTargetFile(void) const; 64 65 // Set/Get whether or not the target file actually exists 66 void SetTargetExists(bool exists); 67 bool GetTargetExists(void) const; 68 69 // Set/Get which DiskFile contains a full undamaged version of the source file 70 void SetCompleteFile(DiskFile *diskfile); 71 DiskFile* GetCompleteFile(void) const; 72 73 // Compute/Get the filename for the final repaired version of the file 74 void ComputeTargetFileName(string path); 75 string TargetFileName(void) const; 76 77 // Get the number of blocks that the file uses BlockCount(void)78 u32 BlockCount(void) const {return blockcount;} 79 80 // Get the relative block number of the first block in the file FirstBlockNumber(void)81 u32 FirstBlockNumber(void) const {return firstblocknumber;} 82 83 // Get the first source DataBlock for the file SourceBlocks(void)84 vector<DataBlock>::iterator SourceBlocks(void) const {return sourceblocks;} 85 86 // Get the first target DataBlock for the file TargetBlocks(void)87 vector<DataBlock>::iterator TargetBlocks(void) const {return targetblocks;} 88 89 protected: 90 DescriptionPacket *descriptionpacket; // The file description packet 91 VerificationPacket *verificationpacket; // The file verification packet 92 93 u32 blockcount; // The number of DataBlocks in the file 94 u32 firstblocknumber; // The block number of the first DataBlock 95 96 vector<DataBlock>::iterator sourceblocks; // The first source DataBlock 97 vector<DataBlock>::iterator targetblocks; // The first target DataBlock 98 99 bool targetexists; // Whether the target file exists 100 DiskFile *targetfile; // The final version of the file 101 DiskFile *completefile; // A complete version of the file 102 103 string targetfilename; // The filename of the target file 104 }; 105 106 #endif // __PAR2REPAIRERSOURCEFILE_H__ 107