| Disk ARchive 2.6.11 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-2020 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 : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
31
32 #ifndef ZAPETTE_HPP
33 #define ZAPETTE_HPP
34
35 #include "../my_config.h"
36 #include "infinint.hpp"
37 #include "generic_file.hpp"
38 #include "integers.hpp"
39 #include "mem_ui.hpp"
40 #include "contextual.hpp"
41
42 namespace libdar
43 {
44
45
48
50
54
55 class zapette : public generic_file, public contextual, protected mem_ui
56 {
57 public:
58
60
65 zapette(const std::shared_ptr<user_interaction> & dialog, generic_file *input, generic_file *output, bool by_the_end);
66 zapette(const zapette & ref) = default;
67 zapette(zapette && ref) noexcept = default;
68 zapette & operator = (const zapette & ref) = default;
69 zapette & operator = (zapette && ref) noexcept = default;
70 ~zapette();
71
72 // inherited methods from generic_file
73 virtual bool skippable(skippability direction, const infinint & amount) override { return true; };
74 virtual bool skip(const infinint &pos) override;
75 virtual bool skip_to_eof() override { if(is_terminated()) throw SRC_BUG; position = file_size; return true; };
76 virtual bool skip_relative(S_I x) override;
77 virtual infinint get_position() const override { if(is_terminated()) throw SRC_BUG; return position; };
78
79 // overwritten inherited methods from contextual
80 virtual void set_info_status(const std::string & s) override;
81 virtual bool is_an_old_start_end_archive() const override;
82 virtual const label & get_data_name() const override;
83
87 infinint get_first_slice_header_size() const;
88
92 infinint get_non_first_slice_header_size() const;
93
94 protected:
95 virtual void inherited_read_ahead(const infinint & amount) override {}; // optimization will be done when zapette will use the messaging_encode/decode exchange format
96 virtual U_I inherited_read(char *a, U_I size) override;
97 virtual void inherited_write(const char *a, U_I size) override;
98 virtual void inherited_sync_write() override {};
99 virtual void inherited_flush_read() override {};
100 virtual void inherited_terminate() override;
101
102 private:
103 generic_file *in, *out;
104 infinint position, file_size;
105 char serial_counter;
106
108
124
125 void make_transfert(U_16 size, const infinint &offset, char *data, const std::string & info, S_I & lu, infinint & arg) const;
126 };
127
129
130 } // end of namespace
131
132 #endif
libdar::zapette::get_position
virtual infinint get_position() const override
get the current read/write position
Definition: zapette.hpp:77
libdar::zapette::get_data_name
virtual const label & get_data_name() const override
obtain the data_name of the archive (label associated with the archive's data)
libdar::label
manage label data structure used in archive slice headers
Definition: label.hpp:43
contextual.hpp
class contextual adds the information of phases in the generic_file
integers.hpp
are defined here basic integer types that tend to be portable
infinint.hpp
switch module to limitint (32 ou 64 bits integers) or infinint
libdar::infinint
the arbitrary large positive integer class
Definition: real_infinint.hpp:62
libdar::zapette::zapette
zapette(const std::shared_ptr< user_interaction > &dialog, generic_file *input, generic_file *output, bool by_the_end)
zapette constructor
libdar::generic_file::is_terminated
bool is_terminated() const
Definition: generic_file.hpp:300
libdar::zapette::set_info_status
virtual void set_info_status(const std::string &s) override
defines the new contextual value
libdar::zapette::inherited_write
virtual void inherited_write(const char *a, U_I size) override
implementation of the write() operation
libdar::zapette::inherited_read
virtual U_I inherited_read(char *a, U_I size) override
implementation of read() operation
libdar::mem_ui
class mem_ui to keep a copy of a user_interaction object
Definition: mem_ui.hpp:55
libdar::zapette::skip
virtual bool skip(const infinint &pos) override
skip at the absolute position
generic_file.hpp
class generic_file is defined here as well as class fichier
libdar::zapette::get_first_slice_header_size
infinint get_first_slice_header_size() const
libdar::zapette::inherited_terminate
virtual void inherited_terminate() override
destructor-like call, except that it is allowed to throw exceptions
libdar::zapette::inherited_flush_read
virtual void inherited_flush_read() override
reset internal engine, flush caches in order to read the data at current position
Definition: zapette.hpp:99
libdar::zapette::skip_to_eof
virtual bool skip_to_eof() override
skip to the end of file
Definition: zapette.hpp:75
libdar::zapette::make_transfert
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...
libdar::generic_file
this is the interface class from which all other data transfer classes inherit
Definition: generic_file.hpp:77
libdar::zapette::inherited_read_ahead
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:95
libdar::zapette::get_non_first_slice_header_size
infinint get_non_first_slice_header_size() const
libdar::zapette::skip_relative
virtual bool skip_relative(S_I x) override
skip relatively to the current position
libdar::contextual
the contextual class adds the information of phases in the generic_file
Definition: contextual.hpp:74
libdar::zapette::is_an_old_start_end_archive
virtual bool is_an_old_start_end_archive() const override
returns whether the archive is a old archive (format < 8)
libdar::zapette::inherited_sync_write
virtual void inherited_sync_write() override
write down any pending data
Definition: zapette.hpp:98
libdar::zapette
zapette emulate a file that is remotely controlled by slave_zapette
Definition: zapette.hpp:56
libdar::zapette::skippable
virtual bool skippable(skippability direction, const infinint &amount) override
whether the implementation is able to skip
Definition: zapette.hpp:73
mem_ui.hpp
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47