Panda3D
Public Member Functions | Public Attributes | List of all members
Patchfile Class Reference

Public Member Functions

 __init__ ()
 Create a patch file and initializes internal data. More...
 
 __init__ (Buffer buffer)
 Create patch file with buffer to patch. More...
 
bool apply (Filename patch_file, Filename file)
 Patches the entire file in one call returns true on success and false on error. More...
 
bool apply (Filename patch_file, Filename orig_file, const Filename target_file)
 Patches the entire file in one call returns true on success and false on error. More...
 
bool build (Filename file_orig, Filename file_new, Filename patch_name)
 This implementation uses the "greedy differencing algorithm" described in the masters thesis "Differential Compression: A Generalized Solution for Binary Files" by Randal C. More...
 
bool getAllowMultifile ()
 See set_allow_multifile(). More...
 
int getFootprintLength ()
 
float getProgress ()
 Returns a value in the range 0..1, representing the amount of progress through the patchfile, during a session. More...
 
const HashVal getResultHash ()
 Returns the MD5 hash for the file after the patch has been applied. More...
 
const HashVal getSourceHash ()
 Returns the MD5 hash for the source file. More...
 
bool hasSourceHash ()
 Returns true if the MD5 hash for the source file is known. More...
 
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). More...
 
int initiate (const Filename patch_file, const Filename orig_file, const Filename target_file)
 Set up to apply the patch to the file. More...
 
int readHeader (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. More...
 
 resetFootprintLength ()
 
int run ()
 Perform one buffer's worth of patching Returns EU_ok while patching Returns EU_success when done If error happens will return one of: EU_error_abort : Patching has not been initiated EU_error_file_invalid : file is corrupted EU_error_invalid_checksum : incompatible patch file EU_error_write_file_rename : could not rename file. More...
 
 setAllowMultifile (bool allow_multifile)
 If this flag is set true, the Patchfile will make a special case for patching Panda Multifiles, if detected, and attempt to patch them on a subfile-by-subfile basis. More...
 
 setFootprintLength (int length)
 

Public Attributes

bool allow_multifile
 See set_allow_multifile(). More...
 
int footprint_length
 
float progress
 Returns a value in the range 0..1, representing the amount of progress through the patchfile, during a session. More...
 
const HashVal result_hash
 Returns the MD5 hash for the file after the patch has been applied. More...
 
const HashVal source_hash
 Returns the MD5 hash for the source file. More...
 

Member Function Documentation

◆ __init__() [1/2]

__init__ ( )

Create a patch file and initializes internal data.

◆ __init__() [2/2]

__init__ ( Buffer  buffer)

Create patch file with buffer to patch.

◆ apply() [1/2]

bool apply ( Filename  patch_file,
Filename  file 
)

Patches the entire file in one call returns true on success and false on error.

This version will delete the patch file and overwrite the original file.

◆ apply() [2/2]

bool apply ( Filename  patch_file,
Filename  orig_file,
const Filename  target_file 
)

Patches the entire file in one call returns true on success and false on error.

This version will not delete any files.

◆ build()

bool build ( Filename  file_orig,
Filename  file_new,
Filename  patch_name 
)

This implementation uses the "greedy differencing algorithm" described in the masters thesis "Differential Compression: A Generalized Solution for Binary Files" by Randal C.

Burns (p.13). For an original file of size M and a new file of size N, this algorithm is O(M) in space and O(M*N) (worst- case) in time. return false on error

◆ getAllowMultifile()

bool getAllowMultifile ( )

See set_allow_multifile().

◆ getFootprintLength()

int getFootprintLength ( )

◆ getProgress()

float getProgress ( )

Returns a value in the range 0..1, representing the amount of progress through the patchfile, during a session.

◆ getResultHash()

const HashVal getResultHash ( )

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

◆ getSourceHash()

const HashVal getSourceHash ( )

Returns the MD5 hash for the source file.

◆ hasSourceHash()

bool hasSourceHash ( )

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

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

◆ initiate() [1/2]

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

◆ initiate() [2/2]

int initiate ( const Filename  patch_file,
const Filename  orig_file,
const Filename  target_file 
)

Set up to apply the patch to the file.

In this form, neither the original file nor the patch file are destroyed.

◆ readHeader()

int readHeader ( 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.

◆ resetFootprintLength()

resetFootprintLength ( )

◆ run()

int run ( )

Perform one buffer's worth of patching Returns EU_ok while patching Returns EU_success when done If error happens will return one of: EU_error_abort : Patching has not been initiated EU_error_file_invalid : file is corrupted EU_error_invalid_checksum : incompatible patch file EU_error_write_file_rename : could not rename file.

◆ setAllowMultifile()

setAllowMultifile ( bool  allow_multifile)

If this flag is set true, the Patchfile will make a special case for patching Panda Multifiles, if detected, and attempt to patch them on a subfile-by-subfile basis.

If this flag is false, the Patchfile will always patch the file on a full-file basis.

This has effect only when building patches; it is not used for applying patches.

◆ setFootprintLength()

setFootprintLength ( int  length)

Member Data Documentation

◆ allow_multifile

bool allow_multifile

See set_allow_multifile().

◆ footprint_length

int footprint_length

◆ progress

float progress

Returns a value in the range 0..1, representing the amount of progress through the patchfile, during a session.

◆ result_hash

const HashVal result_hash

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

◆ source_hash

const HashVal source_hash

Returns the MD5 hash for the source file.