Disk ARchive  2.5.1
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 
44 namespace libdar
45 {
46  class cat_etoile;
47  class cat_entree;
48 
51 
52  enum saved_status
53  {
54  s_saved, //< inode is saved in the archive
55  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.
56  s_not_saved //< inode is not saved in the archive
57  };
58 
60  struct entree_stats
61  {
62  infinint num_x; //< number of file referenced as destroyed since last backup
63  infinint num_d; //< number of directories
64  infinint num_f; //< number of plain files (hard link or not, thus file directory entries)
65  infinint num_c; //< number of char devices
66  infinint num_b; //< number of block devices
67  infinint num_p; //< number of named pipes
68  infinint num_s; //< number of unix sockets
69  infinint num_l; //< number of symbolic links
70  infinint num_D; //< number of Door
71  infinint num_hard_linked_inodes; //< number of inode that have more than one link (inode with "hard links")
72  infinint num_hard_link_entries; //< total number of hard links (file directory entry pointing to \an
73  //< inode already linked in the same or another directory (i.e. hard linked))
74  infinint saved; //< total number of saved inode (unix inode, not inode class) hard links do not count here
75  infinint total; //< total number of inode in archive (unix inode, not inode class) hard links do not count here
76  void clear() { num_x = num_d = num_f = num_c = num_b = num_p
77  = num_s = num_l = num_D = num_hard_linked_inodes
78  = num_hard_link_entries = saved = total = 0; };
79  void add(const cat_entree *ref);
80  void listing(user_interaction & dialog) const;
81  };
82 
84  class cat_entree : public on_pool
85  {
86  public :
99  static cat_entree *read(user_interaction & dialog,
100  memory_pool *pool,
101  const pile_descriptor & f,
102  const archive_version & reading_ver,
103  entree_stats & stats,
104  std::map <infinint, cat_etoile *> & corres,
105  compression default_algo,
106  bool lax,
107  bool only_detruit,
108  bool small);
109 
115  cat_entree(const pile_descriptor & pdesc, bool small);
116 
117  // copy constructor is fine as we only copy the address of pointers
118 
119  // assignment operator is fine too for the same reason
120 
123 
125  virtual ~cat_entree() throw(Ebug) {};
126 
128  virtual bool operator == (const cat_entree & ref) const { return true; };
129  bool operator != (const cat_entree & ref) const { return ! (*this == ref); };
130 
135  void dump(const pile_descriptor & pdesc, bool small) const;
136 
141  void specific_dump(const pile_descriptor & pdesc, bool small) const { inherited_dump(pdesc, small); };
142 
148  virtual void post_constructor(const pile_descriptor & pdesc) {};
149 
151  virtual unsigned char signature() const = 0;
152 
154  virtual cat_entree *clone() const = 0;
155 
163  virtual void change_location(const pile_descriptor & pdesc);
164 
165 
166  protected:
168  virtual void inherited_dump(const pile_descriptor & pdesc, bool small) const;
169 
170 
172  pile *get_pile() const { return pdesc.stack; };
173 
179  compressor *get_compressor_layer() const { return pdesc.compr; };
180 
186  escape *get_escape_layer() const { return pdesc.esc; };
187 
189  generic_file *get_read_cat_layer(bool small) const;
190 
191  private:
192  static const U_I ENTREE_CRC_SIZE;
193 
194  pile_descriptor pdesc;
195  };
196 
197  extern bool compatible_signature(unsigned char a, unsigned char b);
198  extern unsigned char mk_signature(unsigned char base, saved_status state);
199  extern unsigned char get_base_signature(unsigned char a);
200 
202 
203 } // end of namespace
204 
205 #endif
virtual ~cat_entree()
destructor
Definition: cat_entree.hpp:125
holds the statistics contents of a catalogue
Definition: cat_entree.hpp:60
generic_file * get_read_cat_layer(bool small) const
return the adhoc layer in the stack to read from the catalogue objects (except the EA...
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...
compressor * get_compressor_layer() const
Definition: cat_entree.hpp:179
pile * get_pile() const
stack used to read object from (nullptr is returned for object created from filesystem) ...
Definition: cat_entree.hpp:172
virtual cat_entree * clone() const =0
a way to copy the exact type of an object even if pointed to by a parent class pointer ...
void specific_dump(const pile_descriptor &pdesc, bool small) const
Definition: cat_entree.hpp:141
virtual unsigned char signature() const =0
inherited class signature
defines the interaction between libdar and the user.Three classes are defined
class escape definition, used for sequential reading of archivesThe class escape is used to insert es...
virtual bool operator==(const cat_entree &ref) const
returns true if the two object have the same content
Definition: cat_entree.hpp:128
optimization structure to quickly access some commonly used layers of a stack of generic_file ...
virtual void inherited_dump(const pile_descriptor &pdesc, bool small) const
inherited class may overload this method but shall first call the parent's inherited_dump() in the ov...
switch module to limitint (32 ou 64 bits integers) or infinint
static cat_entree * read(user_interaction &dialog, memory_pool *pool, const pile_descriptor &f, const archive_version &reading_ver, entree_stats &stats, std::map< infinint, cat_etoile * > &corres, compression default_algo, bool lax, bool only_detruit, bool small)
escape * get_escape_layer() const
Definition: cat_entree.hpp:186
compression class for gzip and bzip2 algorithms
Definition: compressor.hpp:61
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
virtual void change_location(const pile_descriptor &pdesc)
void dump(const pile_descriptor &pdesc, bool small) const
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
class archive_version manages the version of the archive format
the root class from all other inherite for any entry in the catalogue
Definition: cat_entree.hpp:84
cat_entree()
setup an object when read from filesystem
Definition: cat_entree.hpp:122
virtual void post_constructor(const pile_descriptor &pdesc)
Definition: cat_entree.hpp:148
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47