47 #ifndef GENERIC_FILE_HPP
48 #define GENERIC_FILE_HPP
51 #include "../my_config.h"
104 generic_file(
gf_mode m) { rw = m; terminated = no_read_ahead =
false; enable_crc(
false); checksum =
nullptr; };
143 U_I
read(
char *a, U_I size);
148 void write(
const char *a, U_I size);
153 void write(
const std::string & arg);
162 enum skippability { skip_backward, skip_forward };
169 virtual bool skippable(skippability direction,
const infinint & amount) = 0;
176 virtual bool skip(
const infinint & pos) = 0;
216 const infinint & me_read_ahead,
217 const infinint & you_read_ahead,
218 const infinint & crc_size,
233 const infinint & me_read_ahead,
234 const infinint & you_read_ahead,
235 const infinint & crc_size,
237 infinint & err_offset);
245 bool crc_status()
const {
return active_read == &generic_file::read_crc; };
262 void set_mode(
gf_mode x) { rw = x; };
324 void (
generic_file::* active_write)(
const char *a, U_I size);
326 void enable_crc(
bool mode);
328 U_I read_crc(
char *a, U_I size);
329 void write_crc(
const char *a, U_I size);
334 #define CONTEXT_INIT "init"
335 #define CONTEXT_OP "operation"
336 #define CONTEXT_LAST_SLICE "last_slice"
360 contextual() { status =
""; };
361 virtual ~contextual() throw(Ebug) {};
368 virtual void set_info_status(
const std::string & s) { status = s; };
371 virtual std::string get_info_status()
const {
return status; };
374 virtual bool is_an_old_start_end_archive()
const = 0;
380 virtual const label & get_data_name()
const = 0;
virtual void inherited_write(const char *a, U_I size)=0
implementation of the write() operation
are defined here basic integer types that tend to be portable
class crc definition, used to handle Cyclic Redundancy Checks
bool diff(generic_file &f, const infinint &me_read_ahead, const infinint &you_read_ahead, const infinint &crc_size, crc *&value)
compares the contents with the object in argument
virtual infinint get_position() const =0
get the current read/write position
generic_file(const generic_file &ref)
copy constructor
define the datastructure "label" used to identify slice membership to an archive
void flush_read()
be ready to read at current position, reseting all pending data for reading, cached and in compressio...
virtual bool skip(const infinint &pos)=0
U_I read(char *a, U_I size)
read data from the generic_file
virtual void read_ahead(const infinint &amount)
void ignore_read_ahead(bool mode)
virtual ~generic_file()
virtual destructor, this let inherited destructor to be called even from a generic_file pointer to an...
virtual void inherited_flush_read()=0
gf_mode
generic_file openning modes
S_I read_back(char &a)
skip back one char, read on char and skip back one char
virtual bool skip_relative(S_I x)=0
skip relatively to the current position
bool is_terminated() const
crc * get_crc()
get CRC of the transfered date since last reset
virtual void inherited_sync_write()=0
write down any pending data
void terminate() const
destructor-like call, except that it is allowed to throw exceptions
defines the interaction between libdar and the user.Three classes are defined
const char * generic_file_get_name(gf_mode mode)
provides a human readable string defining the gf_mode given in argument
here is the definition of the path classthe path class handle path and provide several operation on t...
to be able to cancel libdar operation while running in a given thread.the class thread_cancellation i...
generic_file(gf_mode m)
main constructor
const generic_file & operator=(const generic_file &ref)
assignment operator
virtual void inherited_terminate()=0
destructor-like call, except that it is allowed to throw exceptions
gf_mode get_mode() const
retreive the openning mode for this object
switch module to limitint (32 ou 64 bits integers) or infinint
virtual U_I inherited_read(char *a, U_I size)=0
implementation of read() operation
bool crc_status() const
to known whether CRC calculation is activated or not
virtual void inherited_read_ahead(const infinint &amount)=0
exception used to signal a bug. A bug is triggered when reaching some code that should never be reach...
this is the interface class from which all other data transfer classes inherit
void write(const char *a, U_I size)
write data to the generic_file
this is the base class of object that can be allocated on a memory pool
virtual void copy_to(generic_file &ref)
copy all data from current position to the object in argument
void sync_write()
write any pending data
void reset_crc(const infinint &width)
reset CRC on read or writen data
the arbitrary large positive integer class
virtual bool skip_to_eof()=0
skip to the end of file
libdar namespace encapsulate all libdar symbols
virtual bool skippable(skippability direction, const infinint &amount)=0
S_I read_forward(char &a)
read one char