![]() |
Disk ARchive
2.5.2
Full featured and portable backup and archiving tool
|
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 void modify(const infinint & new_offset, const infinint & new_size); 00070 void modify(const infinint & new_offset); 00072 void modify() { modify(0); }; 00073 00075 bool skippable(skippability direction, const infinint & amount); 00077 bool skip(const infinint & pos); 00079 bool skip_to_eof(); 00081 bool skip_relative(S_I x); 00083 infinint get_position() const { return current; }; 00084 00092 void check_underlying_position_while_reading_or_writing(bool mode) { check_pos = mode ; }; 00093 00094 00095 protected : 00097 void inherited_read_ahead(const infinint & amount); 00099 U_I inherited_read(char *a, U_I size); 00101 void inherited_write(const char *a, U_I size); 00102 void inherited_sync_write() { ref->sync_write(); } 00103 void inherited_flush_read() {}; 00104 void inherited_terminate() {if(own_ref) ref->terminate(); }; 00105 00106 private : 00107 infinint start; //< offset in the global generic file to start at 00108 infinint sz; //< length of the portion to consider 00109 generic_file *ref; //< global generic file of which to take a piece 00110 infinint current; //< inside position of the next read or write 00111 bool own_ref; //< whether we own ref (and must destroy it when no more needed) 00112 bool limited; //< whether the sz argument is to be considered 00113 bool check_pos; //< whether to check and eventually adjust (seek) the position of the underlying layer at each read or write 00114 00115 void set_back_current_position(); 00116 }; 00117 00119 00120 } // end of namespace 00121 00122 #endif