Disk ARchive
2.4.2
|
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: scrambler.hpp,v 1.21 2011/04/17 13:12:30 edrusb Rel $ 00022 // 00023 /*********************************************************************/ 00024 00028 00029 #ifndef SCRAMBLER_HPP 00030 #define SCRAMBLER_HPP 00031 00032 #include "../my_config.h" 00033 #include <string> 00034 #include "infinint.hpp" 00035 #include "generic_file.hpp" 00036 #include "erreurs.hpp" 00037 #include "infinint.hpp" 00038 #include "secu_string.hpp" 00039 00040 namespace libdar 00041 { 00042 00045 00046 class scrambler : public generic_file 00047 { 00048 public: 00049 scrambler(const secu_string & pass, generic_file & hidden_side); 00050 scrambler(const scrambler & ref) : generic_file(ref) { throw SRC_BUG; }; 00051 ~scrambler() { if(buffer != NULL) delete [] buffer; }; 00052 00053 const scrambler & operator = (const scrambler & ref) { throw SRC_BUG; }; 00054 00055 bool skip(const infinint & pos) { if(ref == NULL) throw SRC_BUG; return ref->skip(pos); }; 00056 bool skip_to_eof() { if(ref==NULL) throw SRC_BUG; return ref->skip_to_eof(); }; 00057 bool skip_relative(S_I x) { if(ref == NULL) throw SRC_BUG; return ref->skip_relative(x); }; 00058 infinint get_position() { if(ref == NULL) throw SRC_BUG; return ref->get_position(); }; 00059 00060 protected: 00061 U_I inherited_read(char *a, U_I size); 00062 void inherited_write(const char *a, U_I size); 00063 void inherited_sync_write() {}; // nothing to do 00064 void inherited_terminate() {}; // nothing to do 00065 00066 private: 00067 std::string key; 00068 U_32 len; 00069 generic_file *ref; 00070 unsigned char *buffer; 00071 U_I buf_size; 00072 }; 00073 00074 } // end of namespace 00075 00076 #endif