![]() |
Disk ARchive
2.5.2
Full featured and portable backup and archiving tool
|
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 00033 00034 #ifndef ESCAPE_CATALOGUE_HPP 00035 #define ESCAPE_CATALOGUE_HPP 00036 00037 #include "../my_config.h" 00038 00039 #include "catalogue.hpp" 00040 #include "escape.hpp" 00041 #include "pile.hpp" 00042 00043 namespace libdar 00044 { 00045 00048 00049 class escape_catalogue : public catalogue 00050 { 00051 public: 00052 00054 escape_catalogue(user_interaction & dialog, 00055 const pile_descriptor & x_pdesc, 00056 const datetime & root_last_modif, 00057 const label & data_name); 00058 00060 escape_catalogue(user_interaction & dialog, //< user interaction 00061 const pile_descriptor & x_pdesc, //< stack descriptor where to write to 00062 const header_version & ver, //< archive header version read 00063 const std::list<signator> & known_signatories, //< signatories that signed the archive header, to be compared with internal catalogue when reaching the end of the archive 00064 bool lax = false); //< whether to use lax mode 00065 escape_catalogue(const escape_catalogue & ref) : catalogue(ref) { copy_from(ref); }; 00066 const escape_catalogue & operator = (const escape_catalogue &ref); 00067 ~escape_catalogue() { destroy(); }; 00068 00069 // inherited from catalogue 00070 void pre_add(const cat_entree *ref) const; 00071 void pre_add_ea(const cat_entree *ref) const; 00072 void pre_add_crc(const cat_entree *ref) const; 00073 void pre_add_dirty() const; 00074 void pre_add_ea_crc(const cat_entree *ref) const; 00075 void pre_add_waste_mark() const; 00076 void pre_add_failed_mark() const; 00077 void pre_add_fsa(const cat_entree *ref) const; 00078 void pre_add_fsa_crc(const cat_entree *ref) const; 00079 escape *get_escape_layer() const { return pdesc.esc; }; 00080 00081 void reset_read() const; 00082 void end_read() const; 00083 void skip_read_to_parent_dir() const; 00084 bool read(const cat_entree * & ref) const; 00085 bool read_if_present(std::string *name, const cat_nomme * & ref) const; 00086 void tail_catalogue_to_current_read(); 00087 bool read_second_time_dir() const { return status == ec_detruits; }; 00088 00089 private: 00090 enum state 00091 { 00092 ec_init, //< state in which no one file has yet been searched in the archive 00093 ec_marks, //< state in which we find the next file using escape sequence marks 00094 ec_eod, //< state in which the archive is missing trailing EOD entries, due to user interruption, thus returning EOD in enough number to get back to the root directory 00095 ec_signature, //< state in which we compare inline and internal catalogues 00096 ec_detruits, //< state in which which detruits objects are returned from the catalogue 00097 ec_completed //< state in which the escape_catalogue object is completed and has all information in memory as a normal catalogue 00098 }; 00099 00100 pile_descriptor pdesc; 00101 header_version x_ver; 00102 std::list<signator> known_sig; 00103 bool x_lax; 00104 std::map <infinint, cat_etoile *> corres; 00105 state status; 00106 catalogue *cat_det; //< holds the final catalogue's detruit objects when no more file can be read from the archive 00107 infinint min_read_offset; //< next offset in archive should be greater than that to identify a mark 00108 infinint depth; //< directory depth of archive being read sequentially 00109 infinint wait_parent_depth; //< ignore any further entry while depth is less than wait_parent_depth. disabled is set to zero 00110 00111 void set_esc_and_stack(const pile_descriptor & x_pdesc); 00112 void copy_from(const escape_catalogue & ref); 00113 void destroy(); 00114 void merge_cat_det(); 00115 void reset_reading_process(); 00116 }; 00117 00119 00120 } // end of namespace 00121 00122 #endif