39 class EXPCL_PANDA_EXPRESS Patchfile {
42 explicit Patchfile(PT(
Buffer) buffer);
46 int read_header(
const Filename &patch_file);
57 INLINE PN_stdfloat get_progress()
const;
58 MAKE_PROPERTY(progress, get_progress);
60 INLINE
void set_allow_multifile(
bool allow_multifile);
61 INLINE
bool get_allow_multifile();
62 MAKE_PROPERTY(allow_multifile, get_allow_multifile, set_allow_multifile);
64 INLINE
void set_footprint_length(
int length);
65 INLINE
int get_footprint_length();
66 INLINE
void reset_footprint_length();
67 MAKE_PROPERTY(footprint_length, get_footprint_length, set_footprint_length);
69 INLINE
bool has_source_hash()
const;
70 INLINE
const HashVal &get_source_hash()
const;
71 INLINE
const HashVal &get_result_hash()
const;
72 MAKE_PROPERTY2(source_hash, has_source_hash, get_source_hash);
73 MAKE_PROPERTY(result_hash, get_result_hash);
76 int internal_read_header(
const Filename &patch_file);
77 void init(PT(
Buffer) buffer);
82 void build_hash_link_tables(
const char *buffer_orig, uint32_t length_orig,
83 uint32_t *hash_table, uint32_t *link_table);
84 uint32_t calc_hash(
const char *buffer);
85 void find_longest_match(uint32_t new_pos, uint32_t ©_pos, uint16_t ©_length,
86 uint32_t *hash_table, uint32_t *link_table,
const char* buffer_orig,
87 uint32_t length_orig,
const char* buffer_new, uint32_t length_new);
88 uint32_t calc_match_length(
const char* buf1,
const char* buf2, uint32_t max_length,
91 void emit_ADD(std::ostream &write_stream, uint32_t length,
const char* buffer);
92 void emit_COPY(std::ostream &write_stream, uint32_t length, uint32_t COPY_pos);
93 void emit_add_and_copy(std::ostream &write_stream,
94 uint32_t add_length,
const char *add_buffer,
95 uint32_t copy_length, uint32_t copy_pos);
96 void cache_add_and_copy(std::ostream &write_stream,
97 uint32_t add_length,
const char *add_buffer,
98 uint32_t copy_length, uint32_t copy_pos);
99 void cache_flush(std::ostream &write_stream);
101 void write_header(std::ostream &write_stream,
102 std::istream &stream_orig, std::istream &stream_new);
103 void write_terminator(std::ostream &write_stream);
105 bool compute_file_patches(std::ostream &write_stream,
106 uint32_t offset_orig, uint32_t offset_new,
107 std::istream &stream_orig, std::istream &stream_new);
108 bool compute_mf_patches(std::ostream &write_stream,
109 uint32_t offset_orig, uint32_t offset_new,
110 std::istream &stream_orig, std::istream &stream_new);
114 inline bool operator < (
const TarSubfile &other)
const {
115 return _name < other._name;
118 std::streampos _header_start;
119 std::streampos _data_start;
120 std::streampos _data_end;
125 bool read_tar(TarDef &tar, std::istream &stream);
126 bool compute_tar_patches(std::ostream &write_stream,
127 uint32_t offset_orig, uint32_t offset_new,
128 std::istream &stream_orig, std::istream &stream_new,
129 TarDef &tar_orig, TarDef &tar_new);
133 static std::istream *_tar_istream;
135 static int tar_openfunc(
const char *filename,
int oflags, ...);
136 static int tar_closefunc(
int fd);
137 static ssize_t tar_readfunc(
int fd,
void *buffer,
size_t nbytes);
138 static ssize_t tar_writefunc(
int fd,
const void *buffer,
size_t nbytes);
141 bool do_compute_patches(
const Filename &file_orig,
const Filename &file_new,
142 std::ostream &write_stream,
143 uint32_t offset_orig, uint32_t offset_new,
144 std::istream &stream_orig, std::istream &stream_new);
146 bool patch_subfile(std::ostream &write_stream,
147 uint32_t offset_orig, uint32_t offset_new,
149 IStreamWrapper &stream_orig, std::streampos orig_start, std::streampos orig_end,
150 IStreamWrapper &stream_new, std::streampos new_start, std::streampos new_end);
152 static const uint32_t _HASH_BITS;
153 static const uint32_t _HASHTABLESIZE;
154 static const uint32_t _DEFAULT_FOOTPRINT_LENGTH;
155 static const uint32_t _NULL_VALUE;
156 static const uint32_t _MAX_RUN_LENGTH;
157 static const uint32_t _HASH_MASK;
159 bool _allow_multifile;
160 uint32_t _footprint_length;
162 uint32_t *_hash_table;
165 uint32_t _last_copy_pos;
167 std::string _cache_add_data;
168 uint32_t _cache_copy_start;
169 uint32_t _cache_copy_length;
177 uint16_t _version_number;
183 uint32_t _total_bytes_to_process;
184 uint32_t _total_bytes_processed;
186 std::istream *_patch_stream;
187 pofstream _write_stream;
188 std::istream *_origfile_stream;
193 bool _rename_output_to_orig;
194 bool _delete_patchfile;
196 static const uint32_t _v0_magic_number;
197 static const uint32_t _magic_number;
198 static const uint16_t _current_version;
203 #endif // HAVE_OPENSSL