|
Disk ARchive
2.4.12
|
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 00028 00029 #ifndef TRONC_HPP 00030 #define TRONC_HPP 00031 00032 #include "../my_config.h" 00033 #include "infinint.hpp" 00034 #include "generic_file.hpp" 00035 00036 namespace libdar 00037 { 00040 00042 00043 class tronc : public generic_file 00044 { 00045 public : 00047 00052 tronc(generic_file *f, const infinint &offset, const infinint &size, bool own_f = false); 00053 tronc(generic_file *f, const infinint &offset, const infinint &size, gf_mode mode, bool own_f = false); 00054 00057 tronc(generic_file *f, const infinint &offset, bool own_f = false); 00058 tronc(generic_file *f, const infinint &offset, gf_mode mode, bool own_f = false); 00059 00061 ~tronc() 00062 { 00063 if(own_ref) 00064 delete ref; 00065 }; 00066 00068 bool skip(const infinint & pos); 00070 bool skip_to_eof(); 00072 bool skip_relative(S_I x); 00074 infinint get_position() { return current; }; 00075 00076 #ifdef LIBDAR_SPECIAL_ALLOC 00077 USE_SPECIAL_ALLOC(tronc); 00078 #endif 00079 protected : 00081 U_I inherited_read(char *a, U_I size); 00083 void inherited_write(const char *a, U_I size); 00084 void inherited_sync_write() { ref->sync_write(); } 00085 void inherited_terminate() {if(own_ref) ref->terminate(); }; 00086 00087 private : 00088 infinint start; //< offset in the global generic file to start at 00089 infinint sz; //< length of the portion to consider 00090 generic_file *ref; //< global generic file of which to take a piece 00091 infinint current; //< inside position of the next read or write 00092 bool own_ref; //< whether we own ref (and must destroy it when no more needed) 00093 bool limited; //< whether the sz argument is to be considered 00094 00095 void set_back_current_position(); 00096 }; 00097 00099 00100 } // end of namespace 00101 00102 #endif
1.7.6.1