Disk ARchive  2.4.5
 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 // $Id: zapette.hpp,v 1.25 2011/04/17 13:12:30 edrusb Rel $
22 //
23 /*********************************************************************/
24 //
25 
35 
36 #ifndef ZAPETTE_HPP
37 #define ZAPETTE_HPP
38 
39 #include "../my_config.h"
40 #include "infinint.hpp"
41 #include "generic_file.hpp"
42 #include "integers.hpp"
43 
44 namespace libdar
45 {
46 
47 
50 
52 
57  class zapette : public generic_file, public contextual, protected mem_ui
58  {
59  public:
60 
62 
66  zapette(user_interaction & dialog, generic_file *input, generic_file *output);
67  ~zapette();
68 
69  // inherited methods from generic_file
70  bool skip(const infinint &pos);
71  bool skip_to_eof() { if(is_terminated()) throw SRC_BUG; position = file_size; return true; };
72  bool skip_relative(S_I x);
73  infinint get_position() { if(is_terminated()) throw SRC_BUG; return position; };
74 
75  // overwritten inherited methods from contextual
76  void set_info_status(const std::string & s);
77  bool is_an_old_start_end_archive() const;
78  const label & get_data_name() const;
79 
80  protected:
81  U_I inherited_read(char *a, U_I size);
82  void inherited_write(const char *a, U_I size);
84  void inherited_terminate();
85 
86  private:
87  generic_file *in, *out;
88  infinint position, file_size;
89  char serial_counter;
90 
92 
108 
109  void make_transfert(U_16 size, const infinint &offset, char *data, const std::string & info, S_I & lu, infinint & arg) const;
110  };
111 
113 
118  {
119  public:
120 
122 
126  slave_zapette(generic_file *input, generic_file *output, generic_file *data);
127  ~slave_zapette();
128 
129 
131 
134  void action();
135 
136  private:
137  generic_file *in; //< where to read orders from
138  generic_file *out; //< where to send requested info or data to
139  generic_file *src; //< where to read data from
140  contextual *src_ctxt; //< same as src but seen as contextual
141  };
142 
144 
145 } // end of namespace
146 
147 #endif