Disk ARchive  2.4.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
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 
00031 
00032 #ifndef ZAPETTE_HPP
00033 #define ZAPETTE_HPP
00034 
00035 #include "../my_config.h"
00036 #include "infinint.hpp"
00037 #include "generic_file.hpp"
00038 #include "integers.hpp"
00039 
00040 namespace libdar
00041 {
00042 
00043 
00046 
00048 
00053     class zapette : public generic_file, public contextual, protected mem_ui
00054     {
00055     public:
00056 
00058 
00063         zapette(user_interaction & dialog, generic_file *input, generic_file *output, bool by_the_end);
00064         ~zapette();
00065 
00066             // inherited methods from generic_file
00067         bool skip(const infinint &pos);
00068         bool skip_to_eof() { if(is_terminated()) throw SRC_BUG; position = file_size; return true; };
00069         bool skip_relative(S_I x);
00070         infinint get_position() { if(is_terminated()) throw SRC_BUG; return position; };
00071 
00072             // overwritten inherited methods from contextual
00073         void set_info_status(const std::string & s);
00074         bool is_an_old_start_end_archive() const;
00075         const label & get_data_name() const;
00076 
00077     protected:
00078         U_I inherited_read(char *a, U_I size);
00079         void inherited_write(const char *a, U_I size);
00080         void inherited_sync_write() {};
00081         void inherited_terminate();
00082 
00083     private:
00084         generic_file *in, *out;
00085         infinint position, file_size;
00086         char serial_counter;
00087 
00089 
00105 
00106         void make_transfert(U_16 size, const infinint &offset, char *data, const std::string & info, S_I & lu, infinint & arg) const;
00107     };
00108 
00110 
00114     class slave_zapette
00115     {
00116     public:
00117 
00119 
00123         slave_zapette(generic_file *input, generic_file *output, generic_file *data);
00124         ~slave_zapette();
00125 
00126 
00128 
00131         void action();
00132 
00133     private:
00134         generic_file *in;     //< where to read orders from
00135         generic_file *out;    //< where to send requested info or data to
00136         generic_file *src;    //< where to read data from
00137         contextual *src_ctxt; //< same as src but seen as contextual
00138     };
00139 
00141 
00142 } // end of namespace
00143 
00144 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines