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 : dar.linux@free.fr 00020 /*********************************************************************/ 00021 // $Id: elastic.hpp,v 1.5 2004/12/07 18:04:49 edrusb Rel $ 00022 // 00023 /*********************************************************************/ 00024 00028 00029 #ifndef ELASTIC_HPP 00030 #define ELASTIC_HPP 00031 00032 #include "../my_config.h" 00033 00034 #include "integers.hpp" 00035 #include "erreurs.hpp" 00036 #include "infinint.hpp" 00037 #include "generic_file.hpp" 00038 00039 00040 namespace libdar 00041 { 00042 00043 enum elastic_direction { elastic_forward, elastic_backward }; 00044 00046 00051 class elastic 00052 { 00053 public: 00054 elastic(U_32 size) { if(size == 0) throw Erange("elastic::elastic", gettext("zero is not a valid size for an elastic buffer")); taille = size; }; 00055 elastic(const char *buffer, U_32 size, elastic_direction dir); 00056 elastic(generic_file &f, elastic_direction dir); 00057 00058 U_32 dump(char *buffer, U_32 size) const; 00059 U_32 get_size() const { return taille; }; 00060 00061 private: 00062 U_32 taille; // max size of elastic buffer is 4GB which is large enough 00063 00064 void randomize(char *a) const; 00065 }; 00066 00067 } // end of namespace 00068 00069 #endif