Disk ARchive  2.5.2
Full featured and portable backup and archiving tool
cat_entree.hpp
Go to the documentation of this file.
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 
00025 
00026 #ifndef CAT_ENTREE_HPP
00027 #define CAT_ENTREE_HPP
00028 
00029 #include "../my_config.h"
00030 
00031 extern "C"
00032 {
00033 } // end extern "C"
00034 
00035 #include "infinint.hpp"
00036 #include "user_interaction.hpp"
00037 #include "pile.hpp"
00038 #include "escape.hpp"
00039 #include "on_pool.hpp"
00040 #include "archive_version.hpp"
00041 #include "compressor.hpp"
00042 #include "pile_descriptor.hpp"
00043 
00044 namespace libdar
00045 {
00046     class cat_etoile;
00047     class cat_entree;
00048 
00051 
00052     enum saved_status
00053     {
00054     s_saved,      //< inode is saved in the archive
00055     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.
00056     s_not_saved   //< inode is not saved in the archive
00057     };
00058 
00060     struct entree_stats
00061     {
00062         infinint num_x;                  //< number of file referenced as destroyed since last backup
00063         infinint num_d;                  //< number of directories
00064         infinint num_f;                  //< number of plain files (hard link or not, thus file directory entries)
00065     infinint num_c;                  //< number of char devices
00066     infinint num_b;                  //< number of block devices
00067     infinint num_p;                  //< number of named pipes
00068     infinint num_s;                  //< number of unix sockets
00069     infinint num_l;                  //< number of symbolic links
00070     infinint num_D;                  //< number of Door
00071     infinint num_hard_linked_inodes; //< number of inode that have more than one link (inode with "hard links")
00072         infinint num_hard_link_entries;  //< total number of hard links (file directory entry pointing to \an
00073             //< inode already linked in the same or another directory (i.e. hard linked))
00074         infinint saved; //< total number of saved inode (unix inode, not inode class) hard links do not count here
00075         infinint total; //< total number of inode in archive (unix inode, not inode class) hard links do not count here
00076         void clear() { num_x = num_d = num_f = num_c = num_b = num_p
00077                 = num_s = num_l = num_D = num_hard_linked_inodes
00078                 = num_hard_link_entries = saved = total = 0; };
00079         void add(const cat_entree *ref);
00080         void listing(user_interaction & dialog) const;
00081     };
00082 
00084     class cat_entree : public on_pool
00085     {
00086     public :
00099         static cat_entree *read(user_interaction & dialog,
00100                 memory_pool *pool,
00101                 const pile_descriptor & f,
00102                 const archive_version & reading_ver,
00103                 entree_stats & stats,
00104                 std::map <infinint, cat_etoile *> & corres,
00105                 compression default_algo,
00106                 bool lax,
00107                 bool only_detruit,
00108                 bool small);
00109 
00115     cat_entree(const pile_descriptor & pdesc, bool small);
00116 
00117         // copy constructor is fine as we only copy the address of pointers
00118 
00119         // assignment operator is fine too for the same reason
00120 
00122     cat_entree() {};
00123 
00125         virtual ~cat_entree() throw(Ebug) {};
00126 
00128     virtual bool operator == (const cat_entree & ref) const { return true; };
00129     bool operator != (const cat_entree & ref) const { return ! (*this == ref); };
00130 
00135         void dump(const pile_descriptor & pdesc, bool small) const;
00136 
00141     void specific_dump(const pile_descriptor & pdesc, bool small) const { inherited_dump(pdesc, small); };
00142 
00148     virtual void post_constructor(const pile_descriptor & pdesc) {};
00149 
00151         virtual unsigned char signature() const = 0;
00152 
00154         virtual cat_entree *clone() const = 0;
00155 
00163     virtual void change_location(const pile_descriptor & pdesc);
00164 
00165 
00166     protected:
00168     virtual void inherited_dump(const pile_descriptor & pdesc, bool small) const;
00169 
00170 
00172     pile *get_pile() const { return pdesc.stack; };
00173 
00179     compressor *get_compressor_layer() const { return pdesc.compr; };
00180 
00186     escape *get_escape_layer() const { return pdesc.esc; };
00187 
00189     generic_file *get_read_cat_layer(bool small) const;
00190 
00191     private:
00192     static const U_I ENTREE_CRC_SIZE;
00193 
00194     pile_descriptor pdesc;
00195     };
00196 
00197     extern bool compatible_signature(unsigned char a, unsigned char b);
00198     extern unsigned char mk_signature(unsigned char base, saved_status state);
00199     extern unsigned char get_base_signature(unsigned char a);
00200 
00202 
00203 } // end of namespace
00204 
00205 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines