Disk ARchive  2.4.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
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  bool skip(const infinint & pos);
70  bool skip_to_eof();
72  bool skip_relative(S_I x);
74  infinint get_position() { return current; };
75 
76 #ifdef LIBDAR_SPECIAL_ALLOC
77  USE_SPECIAL_ALLOC(tronc);
78 #endif
79  protected :
81  U_I inherited_read(char *a, U_I size);
83  void inherited_write(const char *a, U_I size);
84  void inherited_sync_write() { ref->sync_write(); }
85  void inherited_terminate() {if(own_ref) ref->terminate(); };
86 
87  private :
88  infinint start; //< offset in the global generic file to start at
89  infinint sz; //< length of the portion to consider
90  generic_file *ref; //< global generic file of which to take a piece
91  infinint current; //< inside position of the next read or write
92  bool own_ref; //< whether we own ref (and must destroy it when no more needed)
93  bool limited; //< whether the sz argument is to be considered
94 
95  void set_back_current_position();
96  };
97 
99 
100 } // end of namespace
101 
102 #endif
void inherited_sync_write()
write down any pending data
Definition: tronc.hpp:84
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 ...
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
virtual destructor, this let inherited destructor to be called even from a generic_file pointer to an...
infinint get_position()
inherited from generic_file
Definition: tronc.hpp:74
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:85
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