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

Patchfile Class Reference

#include <patchfile.h>

List of all members.

Protected Member Functions

 PT (Buffer) _buffer

Protected Attributes

bool _initiated
PN_uint16 _version_number
HashVal _MD5_ofSource
PN_uint32 _source_file_length
HashVal _MD5_ofResult
PN_uint32 _result_file_length
int _total_bytes_processed
ifstream _patch_stream
ofstream _write_stream
ifstream _origfile_stream
Filename _patch_file
Filename _orig_file
Filename _temp_file

Static Protected Attributes

const PN_uint32 _v0_magic_number = 0xfeebfaab
const PN_uint32 _magic_number = 0xfeebfaac
const PN_uint16 _current_version = 2

Private Member Functions

 Patchfile (PT(Buffer) buffer)
 ~Patchfile (void)
bool build (Filename file_orig, Filename file_new, Filename patch_name)
int read_header (const Filename &patch_file)
int initiate (const Filename &patch_file, const Filename &file)
int run (void)
bool apply (Filename &patch_file, Filename &file)
INLINE float get_progress (void) const
INLINE void set_footprint_length (int length)
INLINE int get_footprint_length ()
INLINE void reset_footprint_length ()
INLINE bool has_source_hash () const
INLINE const HashValget_source_hash () const
INLINE const HashValget_result_hash () const
int internal_read_header (const Filename &patch_file)
void init (PT(Buffer) buffer)
void cleanup (void)
void build_hash_link_tables (const char *buffer_orig, PN_uint32 length_orig, PN_uint32 *hash_table, PN_uint32 *link_table)
PN_uint16 calc_hash (const char *buffer)
void find_longest_match (PN_uint32 new_pos, PN_uint32 &copy_pos, PN_uint16 &copy_length, PN_uint32 *hash_table, PN_uint32 *link_table, const char *buffer_orig, PN_uint32 length_orig, const char *buffer_new, PN_uint32 length_new)
PN_uint32 calc_match_length (const char *buf1, const char *buf2, PN_uint32 max_length)
void emit_ADD (ofstream &write_stream, PN_uint16 length, const char *buffer, PN_uint32 ADD_pos)
void emit_COPY (ofstream &write_stream, PN_uint16 length, PN_uint32 COPY_pos, PN_uint32 last_copy_pos, PN_uint32 ADD_pos)

Private Attributes

PUBLISHED __pad0__: Patchfile(void)
PN_uint32 _footprint_length

Static Private Attributes

const PN_uint32 _HASHTABLESIZE = PN_uint32(1) << 16
const PN_uint32 _DEFAULT_FOOTPRINT_LENGTH = 9
const PN_uint32 _NULL_VALUE = PN_uint32(0) - 1
const PN_uint32 _MAX_RUN_LENGTH = (PN_uint32(1) << 16) - 1


Constructor & Destructor Documentation

Patchfile::Patchfile PT(Buffer buffer  )  [private]
 

Definition at line 112 of file patchfile.cxx.

References buffer, and init().

Patchfile::~Patchfile void   )  [private]
 

Definition at line 138 of file patchfile.cxx.

References _initiated, and cleanup().


Member Function Documentation

bool Patchfile::apply Filename &  patch_file,
Filename &  file
[private]
 

Definition at line 439 of file patchfile.cxx.

References EU_success, initiate(), and run().

Referenced by main().

bool Patchfile::build Filename  file_orig,
Filename  file_new,
Filename  patch_name
[private]
 

Definition at line 793 of file patchfile.cxx.

References _current_version, _footprint_length, _HASHTABLESIZE, _magic_number, _MD5_ofResult, _MD5_ofSource, _result_file_length, _source_file_length, StreamWriter::add_uint16(), StreamWriter::add_uint32(), build_hash_link_tables(), emit_ADD(), emit_COPY(), END_PROFILE, find_longest_match(), HashVal::get_value(), md5_a_buffer(), NULL, PN_uint16, PN_uint32, and START_PROFILE.

Referenced by main().

void Patchfile::build_hash_link_tables const char *  buffer_orig,
PN_uint32  length_orig,
PN_uint32 hash_table,
PN_uint32 link_table
[private]
 

Definition at line 578 of file patchfile.cxx.

References _footprint_length, _HASHTABLESIZE, _NULL_VALUE, calc_hash(), END_PROFILE, PN_uint16, PN_uint32, START_PROFILE, and t.

Referenced by build().

PN_uint16 Patchfile::calc_hash const char *  buffer  )  [private]
 

--> TRIED MD5, was not worth it for the execution-time hit on 800Mhz PC

Definition at line 530 of file patchfile.cxx.

References _footprint_length, buffer, HashVal::get_value(), md5_a_buffer(), and PN_uint16.

Referenced by build_hash_link_tables(), and find_longest_match().

PN_uint32 Patchfile::calc_match_length const char *  buf1,
const char *  buf2,
PN_uint32  max_length
[private]
 

Definition at line 676 of file patchfile.cxx.

References length, and PN_uint32.

Referenced by find_longest_match().

void Patchfile::cleanup void   )  [private]
 

Definition at line 149 of file patchfile.cxx.

References _initiated, _origfile_stream, _patch_stream, and _write_stream.

Referenced by run(), and ~Patchfile().

void Patchfile::emit_ADD ofstream &  write_stream,
PN_uint16  length,
const char *  buffer,
PN_uint32  ADD_pos
[private]
 

Definition at line 738 of file patchfile.cxx.

References StreamWriter::add_uint16(), StreamWriter::append_data(), buffer, and length.

Referenced by build().

void Patchfile::emit_COPY ofstream &  write_stream,
PN_uint16  length,
PN_uint32  COPY_pos,
PN_uint32  last_copy_pos,
PN_uint32  ADD_pos
[private]
 

Definition at line 761 of file patchfile.cxx.

References StreamWriter::add_int32(), StreamWriter::add_uint16(), length, and PN_int32.

Referenced by build().

void Patchfile::find_longest_match PN_uint32  new_pos,
PN_uint32 copy_pos,
PN_uint16 copy_length,
PN_uint32 hash_table,
PN_uint32 link_table,
const char *  buffer_orig,
PN_uint32  length_orig,
const char *  buffer_new,
PN_uint32  length_new
[private]
 

Definition at line 692 of file patchfile.cxx.

References _MAX_RUN_LENGTH, _NULL_VALUE, calc_hash(), calc_match_length(), PN_uint16, and PN_uint32.

Referenced by build().

INLINE int Patchfile::get_footprint_length  )  [private]
 

INLINE float Patchfile::get_progress void   )  const [private]
 

INLINE const HashVal& Patchfile::get_result_hash  )  const [private]
 

INLINE const HashVal& Patchfile::get_source_hash  )  const [private]
 

Referenced by run().

INLINE bool Patchfile::has_source_hash  )  const [private]
 

Referenced by run().

void Patchfile::init PT(Buffer buffer  )  [private]
 

Definition at line 122 of file patchfile.cxx.

References _initiated, _version_number, buffer, and reset_footprint_length().

Referenced by Patchfile().

int Patchfile::initiate const Filename &  patch_file,
const Filename &  file
[private]
 

Definition at line 184 of file patchfile.cxx.

References _initiated, _orig_file, _origfile_stream, _temp_file, _total_bytes_processed, _write_stream, EU_error_abort, get_write_error(), internal_read_header(), and NULL.

Referenced by apply(), and Patcher::initiate().

int Patchfile::internal_read_header const Filename &  patch_file  )  [private]
 

Definition at line 459 of file patchfile.cxx.

References _current_version, _magic_number, _MD5_ofResult, _MD5_ofSource, _patch_file, _patch_stream, _result_file_length, _source_file_length, _v0_header_length, _v0_magic_number, _version_number, EU_error_file_invalid, EU_success, StreamReader::get_uint16(), StreamReader::get_uint32(), get_write_error(), PN_uint32, and HashVal::set_value().

Referenced by initiate(), and read_header().

Patchfile::PT Buffer   )  [protected]
 

int Patchfile::read_header const Filename &  patch_file  )  [private]
 

Definition at line 243 of file patchfile.cxx.

References _patch_stream, EU_error_abort, and internal_read_header().

INLINE void Patchfile::reset_footprint_length  )  [private]
 

Referenced by init().

int Patchfile::run void   )  [private]
 

Definition at line 262 of file patchfile.cxx.

References _initiated, _MD5_ofResult, _orig_file, _origfile_stream, _patch_file, _patch_stream, _result_file_length, _temp_file, _total_bytes_processed, _version_number, _write_stream, cleanup(), EU_error_abort, EU_error_invalid_checksum, EU_error_write_file_rename, EU_ok, EU_success, StreamReader::get_int32(), get_source_hash(), StreamReader::get_uint16(), has_source_hash(), keep_temporary_files, md5_a_file(), PN_int32, PN_uint16, and PN_uint32.

Referenced by apply(), and Patcher::run().

INLINE void Patchfile::set_footprint_length int  length  )  [private]
 


Member Data Documentation

PUBLISHED Patchfile::__pad0__ [private]
 

Definition at line 56 of file patchfile.h.

const PN_uint16 Patchfile::_current_version = 2 [static, protected]
 

Definition at line 88 of file patchfile.cxx.

Referenced by build(), and internal_read_header().

const PN_uint32 Patchfile::_DEFAULT_FOOTPRINT_LENGTH = 9 [static, private]
 

Definition at line 91 of file patchfile.cxx.

PN_uint32 Patchfile::_footprint_length [private]
 

Definition at line 104 of file patchfile.h.

Referenced by build(), build_hash_link_tables(), and calc_hash().

const PN_uint32 Patchfile::_HASHTABLESIZE = PN_uint32(1) << 16 [static, private]
 

Definition at line 90 of file patchfile.cxx.

Referenced by build(), and build_hash_link_tables().

bool Patchfile::_initiated [protected]
 

Definition at line 110 of file patchfile.h.

Referenced by cleanup(), init(), initiate(), run(), and ~Patchfile().

const PN_uint32 Patchfile::_magic_number = 0xfeebfaac [static, protected]
 

Definition at line 84 of file patchfile.cxx.

Referenced by build(), and internal_read_header().

const PN_uint32 Patchfile::_MAX_RUN_LENGTH = (PN_uint32(1) << 16) - 1 [static, private]
 

Definition at line 93 of file patchfile.cxx.

Referenced by find_longest_match().

HashVal Patchfile::_MD5_ofResult [protected]
 

Definition at line 117 of file patchfile.h.

Referenced by build(), internal_read_header(), and run().

HashVal Patchfile::_MD5_ofSource [protected]
 

Definition at line 114 of file patchfile.h.

Referenced by build(), and internal_read_header().

const PN_uint32 Patchfile::_NULL_VALUE = PN_uint32(0) - 1 [static, private]
 

Definition at line 92 of file patchfile.cxx.

Referenced by build_hash_link_tables(), and find_longest_match().

Filename Patchfile::_orig_file [protected]
 

Definition at line 126 of file patchfile.h.

Referenced by initiate(), and run().

ifstream Patchfile::_origfile_stream [protected]
 

Definition at line 123 of file patchfile.h.

Referenced by cleanup(), initiate(), and run().

Filename Patchfile::_patch_file [protected]
 

Definition at line 125 of file patchfile.h.

Referenced by internal_read_header(), and run().

ifstream Patchfile::_patch_stream [protected]
 

Definition at line 121 of file patchfile.h.

Referenced by cleanup(), internal_read_header(), read_header(), and run().

PN_uint32 Patchfile::_result_file_length [protected]
 

Definition at line 118 of file patchfile.h.

Referenced by build(), internal_read_header(), and run().

PN_uint32 Patchfile::_source_file_length [protected]
 

Definition at line 115 of file patchfile.h.

Referenced by build(), and internal_read_header().

Filename Patchfile::_temp_file [protected]
 

Definition at line 127 of file patchfile.h.

Referenced by initiate(), and run().

int Patchfile::_total_bytes_processed [protected]
 

Definition at line 119 of file patchfile.h.

Referenced by initiate(), and run().

const PN_uint32 Patchfile::_v0_magic_number = 0xfeebfaab [static, protected]
 

Definition at line 83 of file patchfile.cxx.

Referenced by internal_read_header().

PN_uint16 Patchfile::_version_number [protected]
 

Definition at line 112 of file patchfile.h.

Referenced by init(), internal_read_header(), and run().

ofstream Patchfile::_write_stream [protected]
 

Definition at line 122 of file patchfile.h.

Referenced by cleanup(), initiate(), and run().


The documentation for this class was generated from the following files:
Generated on Fri Apr 18 00:13:04 2003 for Panda by doxygen1.3