18 #include "pandabase.h"
27 #include "datagramIterator.h"
29 #include "pointerTo.h"
31 #include "ordered_vector.h"
32 #include "streamWrapper.h"
41 class EXPCL_PANDAEXPRESS Patchfile {
44 Patchfile(PT(
Buffer) buffer);
48 int read_header(
const Filename &patch_file);
59 INLINE PN_stdfloat get_progress()
const;
61 INLINE
void set_allow_multifile(
bool allow_multifile);
62 INLINE
bool get_allow_multifile();
64 INLINE
void set_footprint_length(
int length);
65 INLINE
int get_footprint_length();
66 INLINE
void reset_footprint_length();
68 INLINE
bool has_source_hash()
const;
69 INLINE
const HashVal &get_source_hash()
const;
70 INLINE
const HashVal &get_result_hash()
const;
73 int internal_read_header(
const Filename &patch_file);
74 void init(PT(
Buffer) buffer);
79 void build_hash_link_tables(
const char *buffer_orig, PN_uint32 length_orig,
80 PN_uint32 *hash_table, PN_uint32 *link_table);
81 PN_uint32 calc_hash(
const char *buffer);
82 void find_longest_match(PN_uint32 new_pos, PN_uint32 ©_pos, PN_uint16 ©_length,
83 PN_uint32 *hash_table, PN_uint32 *link_table,
const char* buffer_orig,
84 PN_uint32 length_orig,
const char* buffer_new, PN_uint32 length_new);
85 PN_uint32 calc_match_length(
const char* buf1,
const char* buf2, PN_uint32 max_length,
86 PN_uint32 min_length);
88 void emit_ADD(ostream &write_stream, PN_uint32 length,
const char* buffer);
89 void emit_COPY(ostream &write_stream, PN_uint32 length, PN_uint32 COPY_pos);
90 void emit_add_and_copy(ostream &write_stream,
91 PN_uint32 add_length,
const char *add_buffer,
92 PN_uint32 copy_length, PN_uint32 copy_pos);
93 void cache_add_and_copy(ostream &write_stream,
94 PN_uint32 add_length,
const char *add_buffer,
95 PN_uint32 copy_length, PN_uint32 copy_pos);
96 void cache_flush(ostream &write_stream);
98 void write_header(ostream &write_stream,
99 istream &stream_orig, istream &stream_new);
100 void write_terminator(ostream &write_stream);
102 bool compute_file_patches(ostream &write_stream,
103 PN_uint32 offset_orig, PN_uint32 offset_new,
104 istream &stream_orig, istream &stream_new);
105 bool compute_mf_patches(ostream &write_stream,
106 PN_uint32 offset_orig, PN_uint32 offset_new,
107 istream &stream_orig, istream &stream_new);
111 inline bool operator < (
const TarSubfile &other)
const {
112 return _name < other._name;
115 streampos _header_start;
116 streampos _data_start;
122 bool read_tar(TarDef &tar, istream &stream);
123 bool compute_tar_patches(ostream &write_stream,
124 PN_uint32 offset_orig, PN_uint32 offset_new,
125 istream &stream_orig, istream &stream_new,
126 TarDef &tar_orig, TarDef &tar_new);
130 static istream *_tar_istream;
132 static int tar_openfunc(
const char *filename,
int oflags, ...);
133 static int tar_closefunc(
int fd);
134 static ssize_t tar_readfunc(
int fd,
void *buffer,
size_t nbytes);
135 static ssize_t tar_writefunc(
int fd,
const void *buffer,
size_t nbytes);
138 bool do_compute_patches(
const Filename &file_orig,
const Filename &file_new,
139 ostream &write_stream,
140 PN_uint32 offset_orig, PN_uint32 offset_new,
141 istream &stream_orig, istream &stream_new);
143 bool patch_subfile(ostream &write_stream,
144 PN_uint32 offset_orig, PN_uint32 offset_new,
146 IStreamWrapper &stream_orig, streampos orig_start, streampos orig_end,
147 IStreamWrapper &stream_new, streampos new_start, streampos new_end);
149 static const PN_uint32 _HASH_BITS;
150 static const PN_uint32 _HASHTABLESIZE;
151 static const PN_uint32 _DEFAULT_FOOTPRINT_LENGTH;
152 static const PN_uint32 _NULL_VALUE;
153 static const PN_uint32 _MAX_RUN_LENGTH;
154 static const PN_uint32 _HASH_MASK;
156 bool _allow_multifile;
157 PN_uint32 _footprint_length;
159 PN_uint32 *_hash_table;
162 PN_uint32 _last_copy_pos;
164 string _cache_add_data;
165 PN_uint32 _cache_copy_start;
166 PN_uint32 _cache_copy_length;
174 PN_uint16 _version_number;
180 PN_uint32 _total_bytes_to_process;
181 PN_uint32 _total_bytes_processed;
183 istream *_patch_stream;
184 pofstream _write_stream;
185 istream *_origfile_stream;
190 bool _rename_output_to_orig;
191 bool _delete_patchfile;
193 static const PN_uint32 _v0_magic_number;
194 static const PN_uint32 _magic_number;
195 static const PN_uint16 _current_version;
198 #include "patchfile.I"
200 #endif // HAVE_OPENSSL
Stores a 128-bit value that represents the hashed contents (typically MD5) of a file or buffer...
A specialization of ordered_vector that emulates a standard STL set: one copy of each element is allo...
The name of a file, such as a texture file or an Egg file.
This class provides a locking wrapper around an arbitrary istream pointer.