Disk ARchive  2.7.15
Full featured and portable backup and archiving tool
zapette.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2024 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // to contact the author, see the AUTHOR file
20 /*********************************************************************/
21 
32 
33 #ifndef ZAPETTE_HPP
34 #define ZAPETTE_HPP
35 
36 #include "../my_config.h"
37 #include "infinint.hpp"
38 #include "generic_file.hpp"
39 #include "integers.hpp"
40 #include "mem_ui.hpp"
41 #include "contextual.hpp"
42 
43 namespace libdar
44 {
45 
46 
49 
51 
55 
56  class zapette : public generic_file, public contextual, protected mem_ui
57  {
58  public:
59 
61 
66  zapette(const std::shared_ptr<user_interaction> & dialog, generic_file *input, generic_file *output, bool by_the_end);
67  zapette(const zapette & ref) = default;
68  zapette(zapette && ref) noexcept = default;
69  zapette & operator = (const zapette & ref) = default;
70  zapette & operator = (zapette && ref) noexcept = default;
71  ~zapette();
72 
73  // inherited methods from generic_file
74  virtual bool skippable(skippability direction, const infinint & amount) override { return true; };
75  virtual bool skip(const infinint &pos) override;
76  virtual bool skip_to_eof() override { if(is_terminated()) throw SRC_BUG; position = file_size; return true; };
77  virtual bool skip_relative(S_I x) override;
78  virtual bool truncatable(const infinint & pos) const override { return false; };
79  virtual infinint get_position() const override { if(is_terminated()) throw SRC_BUG; return position; };
80 
81  // overwritten inherited methods from contextual
82  virtual void set_info_status(const std::string & s) override;
83  virtual bool is_an_old_start_end_archive() const override;
84  virtual const label & get_data_name() const override;
85 
90 
95 
96  protected:
97  virtual void inherited_read_ahead(const infinint & amount) override {}; // optimization will be done when zapette will use the messaging_encode/decode exchange format
98  virtual U_I inherited_read(char *a, U_I size) override;
99  virtual void inherited_write(const char *a, U_I size) override;
100  virtual void inherited_truncate(const infinint & pos) override { throw SRC_BUG; }; // read only object
101  virtual void inherited_sync_write() override {};
102  virtual void inherited_flush_read() override {};
103  virtual void inherited_terminate() override;
104 
105  private:
106  generic_file *in, *out;
107  infinint position, file_size;
108  char serial_counter;
109 
111 
127 
128  void make_transfert(U_16 size, const infinint &offset, char *data, const std::string & info, S_I & lu, infinint & arg) const;
129  };
130 
132 
133 } // end of namespace
134 
135 #endif
the contextual class adds the information of phases in the generic_file
Definition: contextual.hpp:74
this is the interface class from which all other data transfer classes inherit
bool is_terminated() const
the arbitrary large positive integer class
manage label data structure used in archive slice headers
Definition: label.hpp:43
class mem_ui to keep a copy of a user_interaction object
Definition: mem_ui.hpp:55
zapette emulate a file that is remotely controlled by slave_zapette
Definition: zapette.hpp:57
virtual void inherited_read_ahead(const infinint &amount) override
tells the object that several calls to read() will follow to probably obtain at least the given amoun...
Definition: zapette.hpp:97
zapette(const std::shared_ptr< user_interaction > &dialog, generic_file *input, generic_file *output, bool by_the_end)
zapette constructor
infinint get_first_slice_header_size() const
void make_transfert(U_16 size, const infinint &offset, char *data, const std::string &info, S_I &lu, infinint &arg) const
wrapped formatted method to communicate with the slave_zapette located behind the pair of pipes (= tu...
virtual U_I inherited_read(char *a, U_I size) override
implementation of read() operation
virtual bool skip_relative(S_I x) override
skip relatively to the current position
virtual bool truncatable(const infinint &pos) const override
whether the implementation is able to truncate to the given position
Definition: zapette.hpp:78
virtual bool is_an_old_start_end_archive() const override
returns whether the archive is a old archive (format < 8)
virtual void inherited_terminate() override
destructor-like call, except that it is allowed to throw exceptions
virtual void inherited_flush_read() override
reset internal engine, flush caches in order to read the data at current position
Definition: zapette.hpp:102
virtual void inherited_sync_write() override
write down any pending data
Definition: zapette.hpp:101
virtual void inherited_write(const char *a, U_I size) override
implementation of the write() operation
virtual const label & get_data_name() const override
obtain the data_name of the archive (label associated with the archive's data)
virtual bool skip(const infinint &pos) override
skip at the absolute position
virtual void set_info_status(const std::string &s) override
defines the new contextual value
virtual bool skippable(skippability direction, const infinint &amount) override
whether the implementation is able to skip
Definition: zapette.hpp:74
virtual bool skip_to_eof() override
skip to the end of file
Definition: zapette.hpp:76
virtual void inherited_truncate(const infinint &pos) override
truncate file at the give offset
Definition: zapette.hpp:100
infinint get_non_first_slice_header_size() const
virtual infinint get_position() const override
get the current read/write position
Definition: zapette.hpp:79
class contextual adds the information of phases in the generic_file
class generic_file is defined here as well as class fichier
switch module to limitint (32 ou 64 bits integers) or infinint
are defined here basic integer types that tend to be portable
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47