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

Patchfile Class Reference

#include <patchfile.h>

List of all members.

Public Member Functions

 Patchfile (void)
 Patchfile (PointerTo< Buffer > buffer)
 ~Patchfile (void)
bool build (Filename file_orig, Filename file_new, Filename patch_name)
int read_header (const Filename &patch_file)
 Opens the patch file for reading, and gets the header information from the file but does not begin to do any real work.

int initiate (const Filename &patch_file, const Filename &file)
 Set up to apply the patch to the file (original file and patch are destroyed in the process).

int run (void)
 Perform one buffer's worth of patching.

bool apply (Filename &patch_file, Filename &file)
float get_progress (void) const
void set_footprint_length (int length)
int get_footprint_length ()
void reset_footprint_length ()
bool has_source_hash () const
 Returns true if the MD5 hash for the source file is known.

const HashValget_source_hash () const
 Returns the MD5 hash for the source file.

const HashValget_result_hash () const
 Returns the MD5 hash for the file after the patch has been applied.


Protected Attributes

PointerTo< Buffer_buffer
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

int internal_read_header (const Filename &patch_file)
 Reads the header and leaves the patch file open.

void init (PointerTo< 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

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 void   ) 
 

Definition at line 114 of file patchfile.cxx.

Patchfile::Patchfile PointerTo< Buffer buffer  ) 
 

Definition at line 127 of file patchfile.cxx.

References _version_number.

Patchfile::~Patchfile void   ) 
 

Definition at line 157 of file patchfile.cxx.

References _initiated, _origfile_stream, _patch_stream, and _write_stream.


Member Function Documentation

bool Patchfile::apply Filename patch_file,
Filename file
 

Definition at line 477 of file patchfile.cxx.

References _magic_number, _patch_file, _v0_magic_number, and EU_error_file_invalid.

bool Patchfile::build Filename  file_orig,
Filename  file_new,
Filename  patch_name
 

Definition at line 850 of file patchfile.cxx.

References _MD5_ofSource, _source_file_length, and PN_uint32.

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 625 of file patchfile.cxx.

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 575 of file patchfile.cxx.

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

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

Definition at line 725 of file patchfile.cxx.

void Patchfile::cleanup void   )  [private]
 

Definition at line 170 of file patchfile.cxx.

References _orig_file, _origfile_stream, _temp_file, EU_error_abort, get_write_error(), NULL, Filename::open_read(), and Filename::set_binary().

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

Definition at line 791 of file patchfile.cxx.

References Filename::open_read(), Filename::set_binary(), and START_PROFILE.

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 816 of file patchfile.cxx.

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 743 of file patchfile.cxx.

int Patchfile::get_footprint_length  )  [inline]
 

Definition at line 63 of file patchfile.I.

References _DEFAULT_FOOTPRINT_LENGTH, _footprint_length, and INLINE.

float Patchfile::get_progress void   )  const [inline]
 

Definition at line 32 of file patchfile.I.

const HashVal & Patchfile::get_result_hash  )  const [inline]
 

Returns the MD5 hash for the file after the patch has been applied.

Definition at line 121 of file patchfile.I.

const HashVal & Patchfile::get_source_hash  )  const [inline]
 

Returns the MD5 hash for the source file.

Definition at line 105 of file patchfile.I.

bool Patchfile::has_source_hash  )  const [inline]
 

Returns true if the MD5 hash for the source file is known.

(Some early versions of the patch file did not store this information.)

Definition at line 92 of file patchfile.I.

References _MD5_ofResult, and INLINE.

void Patchfile::init PointerTo< Buffer buffer  )  [private]
 

Definition at line 139 of file patchfile.cxx.

References _initiated.

int Patchfile::initiate const Filename patch_file,
const Filename file
 

Set up to apply the patch to the file (original file and patch are destroyed in the process).

Definition at line 211 of file patchfile.cxx.

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

Reads the header and leaves the patch file open.

Definition at line 500 of file patchfile.cxx.

References _MD5_ofSource.

int Patchfile::read_header const Filename patch_file  ) 
 

Opens the patch file for reading, and gets the header information from the file but does not begin to do any real work.

This can be used to query the data stored in the patch.

Definition at line 276 of file patchfile.cxx.

References _buffer, _total_bytes_processed, and _write_stream.

void Patchfile::reset_footprint_length  )  [inline]
 

Definition at line 75 of file patchfile.I.

References _version_number, and INLINE.

int Patchfile::run void   ) 
 

Perform one buffer's worth of patching.

Definition at line 298 of file patchfile.cxx.

References _buffer, _patch_stream, _write_stream, and PN_uint32.

Referenced by Patcher::~Patcher().

void Patchfile::set_footprint_length int  length  )  [inline]
 

Definition at line 50 of file patchfile.I.

References _footprint_length, and INLINE.


Member Data Documentation

PointerTo< Buffer > Patchfile::_buffer [protected]
 

Definition at line 114 of file patchfile.h.

Referenced by read_header(), and run().

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

Definition at line 99 of file patchfile.cxx.

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

Definition at line 102 of file patchfile.cxx.

Referenced by get_footprint_length().

PN_uint32 Patchfile::_footprint_length [private]
 

Definition at line 111 of file patchfile.h.

Referenced by calc_hash(), get_footprint_length(), and set_footprint_length().

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

Definition at line 101 of file patchfile.cxx.

Referenced by calc_hash().

bool Patchfile::_initiated [protected]
 

Definition at line 117 of file patchfile.h.

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

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

Definition at line 95 of file patchfile.cxx.

Referenced by apply().

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

Definition at line 104 of file patchfile.cxx.

HashVal Patchfile::_MD5_ofResult [protected]
 

Definition at line 124 of file patchfile.h.

Referenced by has_source_hash().

HashVal Patchfile::_MD5_ofSource [protected]
 

Definition at line 121 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 103 of file patchfile.cxx.

Referenced by calc_hash().

Filename Patchfile::_orig_file [protected]
 

Definition at line 133 of file patchfile.h.

Referenced by cleanup().

ifstream Patchfile::_origfile_stream [protected]
 

Definition at line 130 of file patchfile.h.

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

Filename Patchfile::_patch_file [protected]
 

Definition at line 132 of file patchfile.h.

Referenced by apply().

ifstream Patchfile::_patch_stream [protected]
 

Definition at line 128 of file patchfile.h.

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

PN_uint32 Patchfile::_result_file_length [protected]
 

Definition at line 125 of file patchfile.h.

PN_uint32 Patchfile::_source_file_length [protected]
 

Definition at line 122 of file patchfile.h.

Referenced by build().

Filename Patchfile::_temp_file [protected]
 

Definition at line 134 of file patchfile.h.

Referenced by cleanup().

int Patchfile::_total_bytes_processed [protected]
 

Definition at line 126 of file patchfile.h.

Referenced by read_header().

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

Definition at line 94 of file patchfile.cxx.

Referenced by apply().

PN_uint16 Patchfile::_version_number [protected]
 

Definition at line 119 of file patchfile.h.

Referenced by Patchfile(), and reset_footprint_length().

ofstream Patchfile::_write_stream [protected]
 

Definition at line 129 of file patchfile.h.

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


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:53:15 2003 for Panda by doxygen1.3