par1repairer.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 #ifndef __PAR1REPAIRER_H__
00021 #define __PAR1REPAIRER_H__
00022 
00023 class Par1Repairer
00024 {
00025 public:
00026   Par1Repairer(void);
00027   ~Par1Repairer(void);
00028 
00029   Result Process(const CommandLine &commandline, bool dorepair);
00030 
00031 protected:
00032   // Load the main PAR file
00033   bool LoadRecoveryFile(string filename);
00034 
00035   // Load other PAR files related to the main PAR file
00036   bool LoadOtherRecoveryFiles(string filename);
00037 
00038   // Load any extra PAR files specified on the command line
00039   bool LoadExtraRecoveryFiles(const list<:extrafile> &extrafiles);
00040 
00041   // Check for the existence of and verify each of the source files
00042   bool VerifySourceFiles(void);
00043 
00044   // Check any other files specified on the command line to see if they are
00045   // actually copies of the source files that have the wrong filename
00046   bool VerifyExtraFiles(const list<:extrafile> &extrafiles);
00047 
00048   // Attempt to match the data in the DiskFile with the source file
00049   bool VerifyDataFile(DiskFile *diskfile, Par1RepairerSourceFile *sourcefile);
00050 
00051   // Determine how many files are missing, damaged etc.
00052   void UpdateVerificationResults(void);
00053 
00054   // Check the verification results and report the details
00055   bool CheckVerificationResults(void);
00056 
00057   // Rename any damaged or missnamed target files.
00058   bool RenameTargetFiles(void);
00059 
00060   // Work out which files are being repaired, create them, and allocate
00061   // target DataBlocks to them, and remember them for later verification.
00062   bool CreateTargetFiles(void);
00063 
00064   // Work out which data blocks are available, which need to be recreated, 
00065   // and compute the appropriate Reed Solomon matrix.
00066   bool ComputeRSmatrix(void);
00067 
00068   // Allocate memory buffers for reading and writing data to disk.
00069   bool AllocateBuffers(size_t memorylimit);
00070 
00071   // Read source data, process it through the RS matrix and write it to disk.
00072   bool ProcessData(u64 blockoffset, size_t blocklength);
00073 
00074   // Verify that all of the reconstructed target files are now correct
00075   bool VerifyTargetFiles(void);
00076 
00077   // Delete all of the partly reconstructed files
00078   bool DeleteIncompleteTargetFiles(void);
00079 
00080 protected:
00081   CommandLine::NoiseLevel   noiselevel;              // How noisy we should be
00082   string                    searchpath;              // Where to find files on disk
00083   DiskFileMap               diskfilemap;             // Map from filename to DiskFile
00084 
00085   map      recoveryblocks;          // The recovery data (mapped by exponent)
00086 
00087   unsigned char            *filelist;
00088   u32                       filelistsize;
00089 
00090   u64                       blocksize;               // The size of recovery and data blocks
00091   u64                       chunksize;               // How much of a block can be processed.
00092 
00093   vector sourcefiles;
00094   vector extrafiles;
00095 
00096   u32                       completefilecount;
00097   u32                       renamedfilecount;
00098   u32                       damagedfilecount;
00099   u32                       missingfilecount;
00100 
00101   list verifylist;
00102 
00103   vector        inputblocks;             // Which DataBlocks will be read from disk
00104   vector        outputblocks;            // Which DataBlocks have to calculated using RS
00105 
00106   ReedSolomon      rs;                      // The Reed Solomon matrix.
00107 
00108   u64                       progress;                // How much data has been processed.
00109   u64                       totaldata;               // Total amount of data to be processed.
00110 
00111   size_t                    inputbuffersize;
00112   u8                       *inputbuffer;             // Buffer for reading DataBlocks (chunksize)
00113   size_t                    outputbufferalignment;
00114   size_t                    outputbuffersize;
00115   u8                       *outputbuffer;            // Buffer for writing DataBlocks (chunksize * missingblockcount)
00116   bool                      ignore16kfilehash;       // The 16k file hash values may be invalid
00117 };
00118 
00119 #endif // __PAR1REPAIRER_H__

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