Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

ChecksumFileCalculator Class Reference

Computes a checksum from a file. More...

#include <checksumutil.hpp>

Inheritance diagram for ChecksumFileCalculator:

Inheritance graph
[legend]
Collaboration diagram for ChecksumFileCalculator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

State calculate (const wxString &fileName, const ArrayChecksum &checksums, wxArrayString &sumValues)
 Calculates the checksums from the given file.

State calculate (const wxString &fileName, wxString &sumValue)
 Calculates the checksum from the given file.

State check (const wxString &fileName, const wxString &value)
 Checks the checksum from the given file.

 ChecksumFileCalculator (Checksum *checksum, ChecksumProgress *progressHandler=NULL)
 Constructor with a checksum instance to use and an optional progress handler.

 ChecksumFileCalculator ()
 Default constructor.


Protected Member Functions

wxFileInputStream * getFileInputStream (const wxString &fileName, State &state)
 Gets a wxFileInputStream for reading the file.

void initBufferSize ()
 Initializes the buffer size for reading files.


Detailed Description

Computes a checksum from a file.

Please note that all the pointers passed to this class are not freed, it is the responsability to the users of this class to free them.

Definition at line 126 of file checksumutil.hpp.


Constructor & Destructor Documentation

ChecksumFileCalculator::ChecksumFileCalculator  ) 
 

Default constructor.

Definition at line 322 of file checksumutil.cpp.

References initBufferSize().

ChecksumFileCalculator::ChecksumFileCalculator Checksum checksum,
ChecksumProgress progressHandler = NULL
 

Constructor with a checksum instance to use and an optional progress handler.

Parameters:
checksum Adress of a Checksum instance class to use for calculating the checksums.
progressHandler Adress of a ChecksumProgress instance class to show the progress (could be NULL).

Definition at line 335 of file checksumutil.cpp.

References initBufferSize().


Member Function Documentation

ChecksumCalculator::State ChecksumFileCalculator::calculate const wxString &  fileName,
const ArrayChecksum &  checksums,
wxArrayString &  sumValues
 

Calculates the checksums from the given file.

Parameters:
fileName Name of the file from which the data will be extracted to compute the checksum. The data are extracted until the end of the file is reached.
checksums Array of checksums to calculate.
sumValues The calculated values of the checksums from the input stream. The array is erased first before adding results. On success ArrayChecksum.GetCount() == sumValues.GetCount(), on failure, sumValues should be empty.
Returns:
  • Ok if the checksum has been successfully calculated.
  • ReadError if a read error has occured.
  • FileNotFound if the file doesn't exist.
  • CantOpenFile if the file can't be opened.
  • Canceled if the user has canceled the calculation.

Definition at line 446 of file checksumutil.cpp.

References calculate(), and getFileInputStream().

ChecksumFileCalculator::State ChecksumFileCalculator::calculate const wxString &  fileName,
wxString &  sumValue
 

Calculates the checksum from the given file.

Parameters:
fileName Name of the file from which the data will be extracted to compute the checksum. The data are extracted until the end of the file is reached.
sumValue The calculated value of the checksum from the input stream.
Returns:
  • Ok if the checksum has been successfully calculated.
  • ReadError if a read error has occured.
  • FileNotFound if the file doesn't exist.
  • CantOpenFile if the file can't be opened.
  • Canceled if the user has canceled the calculation.

Definition at line 413 of file checksumutil.cpp.

References calculate(), and getFileInputStream().

Referenced by ChecksumsListView::addFiles(), dlgBatchCreation::batchCreation(), calculate(), and ChecksumsListView::recompute().

ChecksumFileCalculator::State ChecksumFileCalculator::check const wxString &  fileName,
const wxString &  value
 

Checks the checksum from the given file.

Parameters:
fileName Name of the file from which the data will be extracted to compute the checksum. The data are extracted until the end of the file is reached.
value The value of the checksum which will be compared with the value that will be calculated.
Returns:
  • Ok if the checksum has been successfully calculated and if the two sums are equals.
  • Invalid if the checksum has been successfully calculated and if the two sums are not equals.
  • ReadError if a read error has occured.
  • FileNotFound if the file doesn't exist.
  • CantOpenFile if the file can't be opened.

Definition at line 480 of file checksumutil.cpp.

References check(), and getFileInputStream().

Referenced by ChecksumsListView::check(), check(), and dlgMultiCheck::checkFile().

wxFileInputStream * ChecksumFileCalculator::getFileInputStream const wxString &  fileName,
State state
[protected]
 

Gets a wxFileInputStream for reading the file.

Parameters:
fileName Name of the file from which the input stream will be get.
state After the returning the value of this parameter can be:
  • Ok if the input stream has been successfully created.
  • FileNotFound if the file can't be found.
  • CantOpenFile if the file exists, but can't be opened.
  • Canceled if the user has canceled the calculation.
Returns:
A pointer to the input created from the file name or NULL if an error has occured. The caller is responsible of freeing the memory with the delete operator.

Definition at line 377 of file checksumutil.cpp.

References getFileInputStream().

Referenced by calculate(), check(), and getFileInputStream().

void ChecksumFileCalculator::initBufferSize  )  [protected]
 

Initializes the buffer size for reading files.

Definition at line 347 of file checksumutil.cpp.

References DEF_BUFF_SIZE, AppPrefs::get(), MAX_BUFF_SIZE, and AppPrefs::readLong().

Referenced by ChecksumFileCalculator().


The documentation for this class was generated from the following files:
Generated on Sun May 30 13:38:03 2004 for wxChecksums by doxygen 1.3.7