par2repairersourcefile.h

Go to the documentation of this file.
00001 // This file is part of par2cmdline (a PAR 2.0 compatible file verification and
00002 // repair tool). See https://parchive.sourceforge.net for details of PAR 2.0.
00003 //
00004 // Copyright (c) 2003 Peter Brian Clements
00005 //
00006 // par2cmdline is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 2 of the License, or
00009 // (at your option) any later version.
00010 //
00011 // par2cmdline is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014 // GNU General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00019 //
00020 // Modifications for concurrent processing, Unicode support, and hierarchial
00021 // directory support are Copyright (c) 2007-2008 Vincent Tan.
00022 // Search for "#if WANT_CONCURRENT" for concurrent code.
00023 // Concurrent processing utilises Intel Thread Building Blocks 2.0,
00024 // Copyright (c) 2007 Intel Corp.
00025 
00026 #ifndef __PAR2REPAIRERSOURCEFILE_H__
00027 #define __PAR2REPAIRERSOURCEFILE_H__
00028 
00029 enum MatchType
00030 {
00031   eNoMatch = 0,
00032   ePartialMatch,
00033   eFullMatch
00034 };
00035 
00036 // The Par2RepairerSourceFile object is used during verification and repair
00037 // to record details about a particular source file and the data blocks
00038 // for that file.
00039 
00040 class Par2RepairerSourceFile
00041 {
00042 public:
00043   // Construct the object and set the description and verification packets
00044   Par2RepairerSourceFile(DescriptionPacket  *descriptionpacket,
00045                          VerificationPacket *verificationpacket);
00046   ~Par2RepairerSourceFile(void);
00047 
00048   // Get/Set the description packet
00049   DescriptionPacket* GetDescriptionPacket(void) const {return descriptionpacket;}
00050   void SetDescriptionPacket(DescriptionPacket *descriptionpacket);
00051 
00052   // Get/Set the verification packet
00053   VerificationPacket* GetVerificationPacket(void) const {return verificationpacket;}
00054   void SetVerificationPacket(VerificationPacket *verificationpacket);
00055 
00056   // Record the details as to which data blocks belong to this source
00057   // file and set the length of each allocated block correctly.
00058   void SetBlocks(u32 _blocknumber,
00059                  u32 _blockcount,
00060                  vector::iterator _sourceblocks, 
00061                  vector::iterator _targetblocks,
00062                  u64 blocksize);
00063 
00064   // Determine the block count from the file size and block size.
00065   void SetBlockCount(u64 blocksize);
00066 
00067   // Set/Get which DiskFile will contain the final repaired version of the file
00068   void SetTargetFile(DiskFile *diskfile);
00069   DiskFile* GetTargetFile(void) const;
00070 
00071   // Set/Get whether or not the target file actually exists
00072   void SetTargetExists(bool exists);
00073   bool GetTargetExists(void) const;
00074 
00075   // Set/Get which DiskFile contains a full undamaged version of the source file
00076   void SetCompleteFile(DiskFile *diskfile);
00077   DiskFile* GetCompleteFile(void) const;
00078 
00079   // Compute/Get the filename for the final repaired version of the file
00080   void ComputeTargetFileName(string path);
00081   string TargetFileName(void) const;
00082 
00083   // Get the number of blocks that the file uses
00084   u32 BlockCount(void) const {return blockcount;}
00085 
00086   // Get the relative block number of the first block in the file
00087   u32 FirstBlockNumber(void) const {return firstblocknumber;}
00088 
00089   // Get the first source DataBlock for the file
00090   vector::iterator SourceBlocks(void) const {return sourceblocks;}
00091 
00092   // Get the first target DataBlock for the file
00093   vector::iterator TargetBlocks(void) const {return targetblocks;}
00094 
00095 protected:
00096   DescriptionPacket           *descriptionpacket;   // The file description packet
00097   VerificationPacket          *verificationpacket;  // The file verification packet
00098 
00099   u32                          blockcount;          // The number of DataBlocks in the file
00100   u32                          firstblocknumber;    // The block number of the first DataBlock
00101 
00102   vector::iterator  sourceblocks;        // The first source DataBlock
00103   vector::iterator  targetblocks;        // The first target DataBlock
00104 
00105   bool                         targetexists;        // Whether the target file exists
00106   DiskFile                    *targetfile;          // The final version of the file
00107   DiskFile                    *completefile;        // A complete version of the file
00108 
00109   string                       targetfilename;      // The filename of the target file
00110 };
00111 
00112 #endif // __PAR2REPAIRERSOURCEFILE_H__

Generated on Sun Oct 12 01:45:30 2008 for NNTPGrab by  1.5.4