Disk ARchive  2.5.2
Full featured and portable backup and archiving tool
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 #include "mem_ui.hpp"
00040 
00041 namespace libdar
00042 {
00043 
00044 
00047 
00049 
00054     class zapette : public generic_file, public contextual, protected mem_ui
00055     {
00056     public:
00057 
00059 
00064         zapette(const user_interaction & dialog, generic_file *input, generic_file *output, bool by_the_end);
00065         ~zapette();
00066 
00067             // inherited methods from generic_file
00068     bool skippable(skippability direction, const infinint & amount) { return true; };
00069         bool skip(const infinint &pos);
00070         bool skip_to_eof() { if(is_terminated()) throw SRC_BUG; position = file_size; return true; };
00071         bool skip_relative(S_I x);
00072         infinint get_position() const { if(is_terminated()) throw SRC_BUG; return position; };
00073 
00074         // overwritten inherited methods from contextual
00075         void set_info_status(const std::string & s);
00076     bool is_an_old_start_end_archive() const;
00077     const label & get_data_name() const;
00078 
00079     protected:
00080     void inherited_read_ahead(const infinint & amount) {}; // optimization will be done when zapette will use the messaging_encode/decode exchange format
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_flush_read() {};
00085     void inherited_terminate();
00086 
00087     private:
00088         generic_file *in, *out;
00089         infinint position, file_size;
00090         char serial_counter;
00091 
00093 
00109 
00110     void make_transfert(U_16 size, const infinint &offset, char *data, const std::string & info, S_I & lu, infinint & arg) const;
00111     };
00112 
00114 
00118     class slave_zapette : public on_pool
00119     {
00120     public:
00121 
00123 
00127         slave_zapette(generic_file *input, generic_file *output, generic_file *data);
00128         ~slave_zapette();
00129 
00130 
00132 
00135         void action();
00136 
00137     private:
00138         generic_file *in;     //< where to read orders from
00139     generic_file *out;    //< where to send requested info or data to
00140     generic_file *src;    //< where to read data from
00141     contextual *src_ctxt; //< same as src but seen as contextual
00142     };
00143 
00145 
00146 } // end of namespace
00147 
00148 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines