Disk ARchive  2.4.2
zapette.hpp
Go to the documentation of this file.
00001 /*********************************************************************/
00002 // dar - disk archive - a backup/restoration program
00003 // Copyright (C) 2002-2052 Denis Corbin
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 //
00019 // to contact the author : http://dar.linux.free.fr/email.html
00020 /*********************************************************************/
00021 // $Id: zapette.hpp,v 1.25 2011/04/17 13:12:30 edrusb Rel $
00022 //
00023 /*********************************************************************/
00024 //
00025 
00035 
00036 #ifndef ZAPETTE_HPP
00037 #define ZAPETTE_HPP
00038 
00039 #include "../my_config.h"
00040 #include "infinint.hpp"
00041 #include "generic_file.hpp"
00042 #include "integers.hpp"
00043 
00044 namespace libdar
00045 {
00046 
00047 
00050 
00052 
00057     class zapette : public generic_file, public contextual, protected mem_ui
00058     {
00059     public:
00060 
00062 
00066         zapette(user_interaction & dialog, generic_file *input, generic_file *output);
00067         ~zapette();
00068 
00069             // inherited methods from generic_file
00070         bool skip(const infinint &pos);
00071         bool skip_to_eof() { if(is_terminated()) throw SRC_BUG; position = file_size; return true; };
00072         bool skip_relative(S_I x);
00073         infinint get_position() { if(is_terminated()) throw SRC_BUG; return position; };
00074 
00075             // overwritten inherited methods from contextual
00076         void set_info_status(const std::string & s);
00077         bool is_an_old_start_end_archive() const;
00078         const label & get_data_name() const;
00079 
00080     protected:
00081         U_I inherited_read(char *a, U_I size);
00082         void inherited_write(const char *a, U_I size);
00083         void inherited_sync_write() {};
00084         void inherited_terminate();
00085 
00086     private:
00087         generic_file *in, *out;
00088         infinint position, file_size;
00089         char serial_counter;
00090 
00092 
00108 
00109         void make_transfert(U_16 size, const infinint &offset, char *data, const std::string & info, S_I & lu, infinint & arg) const;
00110     };
00111 
00113 
00117     class slave_zapette
00118     {
00119     public:
00120 
00122 
00126         slave_zapette(generic_file *input, generic_file *output, generic_file *data);
00127         ~slave_zapette();
00128 
00129 
00131 
00134         void action();
00135 
00136     private:
00137         generic_file *in;     //< where to read orders from
00138         generic_file *out;    //< where to send requested info or data to
00139         generic_file *src;    //< where to read data from
00140         contextual *src_ctxt; //< same as src but seen as contextual
00141     };
00142 
00144 
00145 } // end of namespace
00146 
00147 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines