Disk ARchive  2.4.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
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 
62  zapette(user_interaction & dialog, generic_file *input, generic_file *output);
63  ~zapette();
64 
65  // inherited methods from generic_file
66  bool skip(const infinint &pos);
67  bool skip_to_eof() { if(is_terminated()) throw SRC_BUG; position = file_size; return true; };
68  bool skip_relative(S_I x);
69  infinint get_position() { if(is_terminated()) throw SRC_BUG; return position; };
70 
71  // overwritten inherited methods from contextual
72  void set_info_status(const std::string & s);
73  bool is_an_old_start_end_archive() const;
74  const label & get_data_name() const;
75 
76  protected:
77  U_I inherited_read(char *a, U_I size);
78  void inherited_write(const char *a, U_I size);
80  void inherited_terminate();
81 
82  private:
83  generic_file *in, *out;
84  infinint position, file_size;
85  char serial_counter;
86 
88 
104 
105  void make_transfert(U_16 size, const infinint &offset, char *data, const std::string & info, S_I & lu, infinint & arg) const;
106  };
107 
109 
114  {
115  public:
116 
118 
122  slave_zapette(generic_file *input, generic_file *output, generic_file *data);
123  ~slave_zapette();
124 
125 
127 
130  void action();
131 
132  private:
133  generic_file *in; //< where to read orders from
134  generic_file *out; //< where to send requested info or data to
135  generic_file *src; //< where to read data from
136  contextual *src_ctxt; //< same as src but seen as contextual
137  };
138 
140 
141 } // end of namespace
142 
143 #endif