42 #include "../my_config.h"
55 #define ESCAPE_FIXED_SEQUENCE_NORMAL 0xAD
56 #define ESCAPE_FIXED_SEQUENCE_SPARSE_FILE 0xAE
58 #define MAX_BUFFER_SIZE 102400
60 #if SSIZE_MAX < MAX_BUFFER_SIZE
61 #undef MAX_BUFFER_SIZE
62 #define MAX_BUFFER_SIZE SSIZE_MAX
72 class escape :
public generic_file
106 escape(generic_file *below,
107 const std::set<sequence_type> & x_unjumpable
109 escape(
const escape & ref) :
generic_file(ref) { copy_from(ref); };
110 escape(escape && ref) noexcept : generic_file(
std::move(ref)) { nullifyptr(); move_from(std::move(ref)); };
111 escape & operator = (
const escape & ref);
112 escape & operator = (escape && ref) noexcept {
generic_file::operator = (std::move(ref)); move_from(std::move(ref));
return *
this; };
117 void add_mark_at_current_position(sequence_type t);
125 bool skip_to_next_mark(sequence_type t,
bool jump);
126 bool next_to_read_is_mark(sequence_type t);
127 bool next_to_read_is_which_mark(sequence_type & t);
129 void add_unjumpable_mark(sequence_type t) {
if(
is_terminated())
throw SRC_BUG; unjumpable.insert(t); };
130 void remove_unjumpable_mark(sequence_type t);
131 bool is_unjumpable_mark(sequence_type t)
const {
return unjumpable.find(t) != unjumpable.end(); };
132 void clear_all_unjumpable_marks() { unjumpable.clear(); };
140 virtual bool skippable(skippability direction,
const infinint & amount)
override;
141 virtual bool skip(
const infinint & pos)
override;
142 virtual bool skip_to_eof()
override;
143 virtual bool skip_relative(S_I x)
override;
144 virtual bool truncatable(
const infinint & pos)
const override {
return x_below->truncatable(pos); };
145 virtual infinint get_position()
const override;
148 virtual void inherited_read_ahead(
const infinint & amount)
override;
149 virtual U_I inherited_read(
char *a, U_I size)
override;
150 virtual void inherited_write(
const char *a, U_I size)
override;
151 virtual void inherited_truncate(
const infinint & pos)
override;
152 virtual void inherited_sync_write()
override { flush_write(); };
153 virtual void inherited_flush_read()
override { flush_write(); clean_read(); };
154 virtual void inherited_terminate()
override { flush_or_clean(); };
156 void change_fixed_escape_sequence(
unsigned char value) { fixed_sequence[0] = value; };
157 bool has_escaped_data_since_last_skip()
const {
return escaped_data_count_since_last_skip > 0; };
164 static constexpr U_I ESCAPE_SEQUENCE_LENGTH = 6;
165 static constexpr U_I INITIAL_WRITE_BUFFER_SIZE = 2*ESCAPE_SEQUENCE_LENGTH;
166 static constexpr U_I INITIAL_READ_BUFFER_SIZE = MAX_BUFFER_SIZE;
167 static const infinint READ_BUFFER_SIZE_INFININT;
176 static const unsigned char usual_fixed_sequence[ESCAPE_SEQUENCE_LENGTH];
181 U_I write_buffer_size;
182 char write_buffer[INITIAL_WRITE_BUFFER_SIZE];
186 U_I escape_seq_offset_in_buffer;
188 U_I read_buffer_size;
189 U_I read_buffer_alloc;
190 std::set<sequence_type> unjumpable;
191 unsigned char fixed_sequence[ESCAPE_SEQUENCE_LENGTH];
192 infinint escaped_data_count_since_last_skip;
193 infinint below_position;
197 void set_fixed_sequence_for(sequence_type t) { fixed_sequence[ESCAPE_SEQUENCE_LENGTH - 1] = type2char(t); };
198 void check_below()
const {
if(x_below ==
nullptr)
throw SRC_BUG; };
201 void flush_or_clean()
216 void nullifyptr() noexcept { x_below =
nullptr; };
217 void copy_from(
const escape & ref);
218 void move_from(escape && ref) noexcept;
219 bool mini_read_buffer();
224 static
char type2char(sequence_type x);
225 static sequence_type char2type(
char x);
233 static U_I trouve_amorce(const
char *a, U_I size, const
unsigned char escape_sequence[ESCAPE_SEQUENCE_LENGTH]);
243 static U_I remove_data_marks_and_stop_at_first_real_mark(
char *a, U_I size, U_I &
delta, const
unsigned char escape_sequence[ESCAPE_SEQUENCE_LENGTH]);
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
bool is_terminated() const
generic_file & operator=(const generic_file &ref)
assignment operator
generic_file(gf_mode m)
main constructor
gf_mode get_mode() const
retreive the openning mode for this object
inode is saved but as delta binary from the content (delta signature) of what was found in the archiv...
libdar namespace encapsulate all libdar symbols