Disk ARchive  2.5.13
Full featured and portable backup and archiving tool
cat_entree.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 
25 
26 #ifndef CAT_ENTREE_HPP
27 #define CAT_ENTREE_HPP
28 
29 #include "../my_config.h"
30 
31 extern "C"
32 {
33 } // end extern "C"
34 
35 #include "infinint.hpp"
36 #include "user_interaction.hpp"
37 #include "pile.hpp"
38 #include "escape.hpp"
39 #include "on_pool.hpp"
40 #include "archive_version.hpp"
41 #include "compressor.hpp"
42 #include "pile_descriptor.hpp"
43 #include "smart_pointer.hpp"
44 
45 namespace libdar
46 {
47  class cat_etoile;
48  class cat_entree;
49 
52 
53  enum saved_status
54  {
55  s_saved, //< inode is saved in the archive
56  s_fake, //< inode is not saved in the archive but is in the archive of reference (isolation context) s_fake is no more used in archive format "08" and above: isolated catalogue do keep the data pointers and s_saved stays a valid status in isolated catalogues.
57  s_not_saved //< inode is not saved in the archive
58  };
59 
61  struct entree_stats
62  {
63  infinint num_x; //< number of file referenced as destroyed since last backup
64  infinint num_d; //< number of directories
65  infinint num_f; //< number of plain files (hard link or not, thus file directory entries)
66  infinint num_c; //< number of char devices
67  infinint num_b; //< number of block devices
68  infinint num_p; //< number of named pipes
69  infinint num_s; //< number of unix sockets
70  infinint num_l; //< number of symbolic links
71  infinint num_D; //< number of Door
72  infinint num_hard_linked_inodes; //< number of inode that have more than one link (inode with "hard links")
73  infinint num_hard_link_entries; //< total number of hard links (file directory entry pointing to \an
74  //< inode already linked in the same or another directory (i.e. hard linked))
75  infinint saved; //< total number of saved inode (unix inode, not inode class) hard links do not count here
76  infinint total; //< total number of inode in archive (unix inode, not inode class) hard links do not count here
77  void clear() { num_x = num_d = num_f = num_c = num_b = num_p
78  = num_s = num_l = num_D = num_hard_linked_inodes
79  = num_hard_link_entries = saved = total = 0; };
80  void add(const cat_entree *ref);
81  void listing(user_interaction & dialog) const;
82  };
83 
85  class cat_entree : public on_pool
86  {
87  public :
100  static cat_entree *read(user_interaction & dialog,
101  memory_pool *pool,
103  const archive_version & reading_ver,
104  entree_stats & stats,
105  std::map <infinint, cat_etoile *> & corres,
106  compression default_algo,
107  bool lax,
108  bool only_detruit,
109  bool small);
110 
116  cat_entree(const smart_pointer<pile_descriptor> & pdesc, bool small);
117 
118  // copy constructor is fine as we only copy the address of pointers
119 
120  // assignment operator is fine too for the same reason
121 
124 
126  virtual ~cat_entree() throw(Ebug) {};
127 
129  virtual bool operator == (const cat_entree & ref) const { return true; };
130  bool operator != (const cat_entree & ref) const { return ! (*this == ref); };
131 
136  void dump(const pile_descriptor & pdesc, bool small) const;
137 
142  void specific_dump(const pile_descriptor & pdesc, bool small) const { inherited_dump(pdesc, small); };
143 
149  virtual void post_constructor(const pile_descriptor & pdesc) {};
150 
152  virtual unsigned char signature() const = 0;
153 
155  virtual cat_entree *clone() const = 0;
156 
164  virtual void change_location(const smart_pointer<pile_descriptor> & pdesc);
165 
166 
167  protected:
169  virtual void inherited_dump(const pile_descriptor & pdesc, bool small) const;
170 
171 
173  pile *get_pile() const { return pdesc.is_null() ? nullptr : pdesc->stack; };
174 
180  compressor *get_compressor_layer() const { return pdesc.is_null() ? nullptr : pdesc->compr; };
181 
187  escape *get_escape_layer() const { return pdesc.is_null() ? nullptr : pdesc->esc; };
188 
190  generic_file *get_read_cat_layer(bool small) const;
191 
192  private:
193  static const U_I ENTREE_CRC_SIZE;
194 
196  };
197 
199 
200 } // end of namespace
201 
202 #endif
virtual ~cat_entree()
destructor
Definition: cat_entree.hpp:126
holds the statistics contents of a catalogue
Definition: cat_entree.hpp:61
void specific_dump(const pile_descriptor &pdesc, bool small) const
Definition: cat_entree.hpp:142
class pile definition. Used to manage a stack of generic_file objects
This is a pure virtual class that is used by libdar when interaction with the user is required...
defines the interaction between libdar and the user.Three classes are defined
pile * get_pile() const
stack used to read object from (nullptr is returned for object created from filesystem) ...
Definition: cat_entree.hpp:173
class escape definition, used for sequential reading of archivesThe class escape is used to insert es...
optimization structure to quickly access some commonly used layers of a stack of generic_file ...
template class implementing memory efficient smart pointer
switch module to limitint (32 ou 64 bits integers) or infinint
compression class for gzip and bzip2 algorithms
Definition: compressor.hpp:67
exception used to signal a bug. A bug is triggered when reaching some code that should never be reach...
Definition: erreurs.hpp:137
compression
the different compression algorithm available
Definition: compressor.hpp:43
this is the interface class from which all other data transfer classes inherit
escape * get_escape_layer() const
Definition: cat_entree.hpp:187
compression engine implementation
class archive_version that rules which archive format to follow
this is the base class of object that can be allocated on a memory pool
the arbitrary large positive integer class
the root class from all other inherite for any entry in the catalogue
Definition: cat_entree.hpp:85
cat_entree()
setup an object when read from filesystem
Definition: cat_entree.hpp:123
virtual void post_constructor(const pile_descriptor &pdesc)
Definition: cat_entree.hpp:149
compressor * get_compressor_layer() const
Definition: cat_entree.hpp:180
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47