Disk ARchive  2.4.15
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 
40 namespace libdar
41 {
42 
43 
46 
48 
53  class zapette : public generic_file, public contextual, protected mem_ui
54  {
55  public:
56 
58 
63  zapette(user_interaction & dialog, generic_file *input, generic_file *output, bool by_the_end);
64  ~zapette();
65 
66  // inherited methods from generic_file
67  bool skip(const infinint &pos);
68  bool skip_to_eof() { if(is_terminated()) throw SRC_BUG; position = file_size; return true; };
69  bool skip_relative(S_I x);
70  infinint get_position() { if(is_terminated()) throw SRC_BUG; return position; };
71 
72  // overwritten inherited methods from contextual
73  void set_info_status(const std::string & s);
74  bool is_an_old_start_end_archive() const;
75  const label & get_data_name() const;
76 
77  protected:
78  U_I inherited_read(char *a, U_I size);
79  void inherited_write(const char *a, U_I size);
81  void inherited_terminate();
82 
83  private:
84  generic_file *in, *out;
85  infinint position, file_size;
86  char serial_counter;
87 
89 
105 
106  void make_transfert(U_16 size, const infinint &offset, char *data, const std::string & info, S_I & lu, infinint & arg) const;
107  };
108 
110 
115  {
116  public:
117 
119 
123  slave_zapette(generic_file *input, generic_file *output, generic_file *data);
124  ~slave_zapette();
125 
126 
128 
131  void action();
132 
133  private:
134  generic_file *in; //< where to read orders from
135  generic_file *out; //< where to send requested info or data to
136  generic_file *src; //< where to read data from
137  contextual *src_ctxt; //< same as src but seen as contextual
138  };
139 
141 
142 } // end of namespace
143 
144 #endif
void inherited_write(const char *a, U_I size)
implementation of the write() operation
are defined here basic integer types that tend to be portable
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
infinint get_position()
get the current read/write position
Definition: zapette.hpp:70
this class answers to order given by a zapette object
Definition: zapette.hpp:114
zapette(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...
bool is_terminated() const
slave_zapette(generic_file *input, generic_file *output, generic_file *data)
slave_zapette constructor
void inherited_sync_write()
write down any pending data
Definition: zapette.hpp:80
bool skip(const infinint &pos)
skip at the absolute position
zapette emulate a file that is remotely controlled by slave_zapette
Definition: zapette.hpp:53
bool skip_to_eof()
skip to the end of file
Definition: zapette.hpp:68
bool skip_relative(S_I x)
skip relatively to the current position
void action()
main execution method for slave_zapette class
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
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
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:43