Disk ARchive  2.5.5
Full featured and portable backup and archiving tool
tronc.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21 
28 
29 #ifndef TRONC_HPP
30 #define TRONC_HPP
31 
32 #include "../my_config.h"
33 #include "infinint.hpp"
34 #include "generic_file.hpp"
35 
36 namespace libdar
37 {
40 
42 
43  class tronc : public generic_file
44  {
45  public :
47 
52  tronc(generic_file *f, const infinint &offset, const infinint &size, bool own_f = false);
53  tronc(generic_file *f, const infinint &offset, const infinint &size, gf_mode mode, bool own_f = false);
54 
57  tronc(generic_file *f, const infinint &offset, bool own_f = false);
58  tronc(generic_file *f, const infinint &offset, gf_mode mode, bool own_f = false);
59 
62  {
63  if(own_ref)
64  delete ref;
65  };
66 
68  void modify(const infinint & new_offset, const infinint & new_size);
70  void modify(const infinint & new_offset);
72  void modify() { modify(0); };
73 
75  bool skippable(skippability direction, const infinint & amount);
77  bool skip(const infinint & pos);
79  bool skip_to_eof();
81  bool skip_relative(S_I x);
83  infinint get_position() const { return current; };
84 
92  void check_underlying_position_while_reading_or_writing(bool mode) { check_pos = mode ; };
93 
94 
95  protected :
97  void inherited_read_ahead(const infinint & amount);
99  U_I inherited_read(char *a, U_I size);
101  void inherited_write(const char *a, U_I size);
102  void inherited_sync_write() { ref->sync_write(); }
104  void inherited_terminate() {if(own_ref) ref->terminate(); };
105 
106  private :
107  infinint start; //< offset in the global generic file to start at
108  infinint sz; //< length of the portion to consider
109  generic_file *ref; //< global generic file of which to take a piece
110  infinint current; //< inside position of the next read or write
111  bool own_ref; //< whether we own ref (and must destroy it when no more needed)
112  bool limited; //< whether the sz argument is to be considered
113  bool check_pos; //< whether to check and eventually adjust (seek) the position of the underlying layer at each read or write
114 
115  void set_back_current_position();
116  };
117 
119 
120 } // end of namespace
121 
122 #endif
void modify()
modify the tronc object to become transparent and allow unrestricted access to the underlyuing object...
Definition: tronc.hpp:72
void inherited_flush_read()
Definition: tronc.hpp:103
infinint get_position() const
inherited from generic_file
Definition: tronc.hpp:83
void inherited_sync_write()
write down any pending data
Definition: tronc.hpp:102
tronc(generic_file *f, const infinint &offset, const infinint &size, bool own_f=false)
constructor
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
bool skippable(skippability direction, const infinint &amount)
inherited from generic_file
void inherited_read_ahead(const infinint &amount)
inherited from generic_file
void check_underlying_position_while_reading_or_writing(bool mode)
Definition: tronc.hpp:92
U_I inherited_read(char *a, U_I size)
inherited from generic_file
~tronc()
destructor
Definition: tronc.hpp:61
gf_mode
generic_file openning modes
void terminate() const
destructor-like call, except that it is allowed to throw exceptions
void inherited_write(const char *a, U_I size)
inherited from generic_file
bool skip(const infinint &pos)
inherited from generic_file
bool skip_to_eof()
inherited from generic_file
switch module to limitint (32 ou 64 bits integers) or infinint
this is the interface class from which all other data transfer classes inherit
void inherited_terminate()
destructor-like call, except that it is allowed to throw exceptions
Definition: tronc.hpp:104
void sync_write()
write any pending data
the arbitrary large positive integer class
makes a segment of a generic_file appear like a real generic_file
Definition: tronc.hpp:43
bool skip_relative(S_I x)
inherited from generic_file
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47