Disk ARchive  2.5.13
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-2052 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 
41 namespace libdar
42 {
43 
44 
47 
49 
54  class zapette : public generic_file, public contextual, protected mem_ui
55  {
56  public:
57 
59 
64  zapette(const user_interaction & dialog, generic_file *input, generic_file *output, bool by_the_end);
65  ~zapette();
66 
67  // inherited methods from generic_file
68  bool skippable(skippability direction, const infinint & amount) { return true; };
69  bool skip(const infinint &pos);
70  bool skip_to_eof() { if(is_terminated()) throw SRC_BUG; position = file_size; return true; };
71  bool skip_relative(S_I x);
72  infinint get_position() const { if(is_terminated()) throw SRC_BUG; return position; };
73 
74  // overwritten inherited methods from contextual
75  void set_info_status(const std::string & s);
76  bool is_an_old_start_end_archive() const;
77  const label & get_data_name() const;
78 
83 
88 
89  protected:
90  void inherited_read_ahead(const infinint & amount) {}; // optimization will be done when zapette will use the messaging_encode/decode exchange format
91  U_I inherited_read(char *a, U_I size);
92  void inherited_write(const char *a, U_I size);
95  void inherited_terminate();
96 
97  private:
98  generic_file *in, *out;
99  infinint position, file_size;
100  char serial_counter;
101 
103 
119 
120  void make_transfert(U_16 size, const infinint &offset, char *data, const std::string & info, S_I & lu, infinint & arg) const;
121  };
122 
124 
128  class slave_zapette : public on_pool
129  {
130  public:
131 
133 
137  slave_zapette(generic_file *input, generic_file *output, generic_file *data);
138  ~slave_zapette();
139 
140 
142 
145  void action();
146 
147  private:
148  generic_file *in; //< where to read orders from
149  generic_file *out; //< where to send requested info or data to
150  generic_file *src; //< where to read data from
151  contextual *src_ctxt; //< same as src but seen as contextual
152  };
153 
155 
156 } // end of namespace
157 
158 #endif
void inherited_write(const char *a, U_I size)
implementation of the write() operation
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
are defined here basic integer types that tend to be portable
infinint get_non_first_slice_header_size() const
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
this class answers to order given by a zapette object
Definition: zapette.hpp:128
zapette(const user_interaction &dialog, generic_file *input, generic_file *output, bool by_the_end)
zapette constructor
This is a pure virtual class that is used by libdar when interaction with the user is required...
infinint get_first_slice_header_size() const
void inherited_sync_write()
write down any pending data
Definition: zapette.hpp:93
bool skip(const infinint &pos)
zapette emulate a file that is remotely controlled by slave_zapette
Definition: zapette.hpp:54
bool skip_to_eof()
skip to the end of file
Definition: zapette.hpp:70
infinint get_position() const
get the current read/write position
Definition: zapette.hpp:72
bool is_terminated() const
bool skip_relative(S_I x)
skip relatively to the current position
U_I inherited_read(char *a, U_I size)
implementation of read() operation
void inherited_terminate()
destructor-like call, except that it is allowed to throw exceptions
switch module to limitint (32 ou 64 bits integers) or infinint
void inherited_flush_read()
Definition: zapette.hpp:94
this is the interface class from which all other data transfer classes inherit
class mem_ui to keep a copy of a user_interaction object
Definition: mem_ui.hpp:53
the arbitrary large positive integer class
bool skippable(skippability direction, const infinint &amount)
Definition: zapette.hpp:68
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
void inherited_read_ahead(const infinint &amount)
Definition: zapette.hpp:90