Disk ARchive  2.4.2
escape_catalogue.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 // $Id: escape_catalogue.hpp,v 1.14.2.1 2011/07/24 10:46:49 edrusb Rel $
00022 //
00023 /*********************************************************************/
00024 
00036 
00037 #ifndef ESCAPE_CATALOGUE_HPP
00038 #define ESCAPE_CATALOGUE_HPP
00039 
00040 #include "../my_config.h"
00041 
00042 #include "catalogue.hpp"
00043 #include "escape.hpp"
00044 
00045 namespace libdar
00046 {
00047 
00050 
00051     class escape_catalogue : public catalogue
00052     {
00053     public:
00054         escape_catalogue(user_interaction & dialog,
00055                          const infinint & root_last_modif,
00056                          const label & data_name, escape *esc_ptr);
00057         escape_catalogue(user_interaction & dialog,        //< user interaction
00058                          const archive_version & reading_ver,  //< archive format
00059                          compression default_algo,         //< default compression algorithm
00060                          generic_file *data_loc,           //< at which layer to read data from
00061                          generic_file *ea_loc,             //< at which layer to read EA from
00062                          escape *esc_ptr,                  //< the escape layer of the stack
00063                          bool lax = false);                //< whether to use lax mode
00064         escape_catalogue(const escape_catalogue & ref) : catalogue(ref) { copy_from(ref); };
00065         const escape_catalogue & operator = (const escape_catalogue &ref);
00066         ~escape_catalogue() { destroy(); };
00067 
00068             // inherited from catalogue
00069         void pre_add(const entree *ref, compressor *compr) const;
00070         void pre_add_ea(const entree *ref, compressor *compr) const;
00071         void pre_add_crc(const entree *ref, compressor *compr) const;
00072         void pre_add_dirty(compressor *compr) const;
00073         void pre_add_ea_crc(const entree *ref, compressor *compr) const;
00074         void pre_add_waste_mark(compressor *compr) const;
00075         void pre_add_failed_mark(compressor *compr) const;
00076         escape *get_escape_layer() const { return esc; };
00077 
00078         void reset_read() const;
00079         void end_read() const;
00080         void skip_read_to_parent_dir() const;
00081         bool read(const entree * & ref) const;
00082         bool read_if_present(std::string *name, const nomme * & ref) const;
00083         void tail_catalogue_to_current_read();
00084         bool read_second_time_dir() const { return status == ec_detruits; };
00085 
00086 #ifdef LIBDAR_SPECIAL_ALLOC
00087         USE_SPECIAL_ALLOC(escape_catalogue);
00088 #endif
00089 
00090     private:
00091         enum state
00092         {
00093             ec_init,   //< state in which no one file has yet been searched in the archive
00094             ec_marks,  //< state in which we find the next file using escape sequence marks
00095             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
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         escape *esc;
00101         archive_version x_reading_ver;
00102         compression x_default_algo;
00103         generic_file *x_data_loc;
00104         generic_file *x_ea_loc;
00105         bool x_lax;
00106         std::map <infinint, etoile *> corres;
00107         state status;
00108         catalogue *cat_det; //< holds the final catalogue's detruit objects when no more file can be read from the archive
00109         infinint min_read_offset;   //< next offset in archive should be greater than that to identify a mark
00110         infinint depth;             //< directory depth of archive being read sequentially
00111         infinint wait_parent_depth; //< ignore any further entry while depth is less than wait_parent_depth. disabled is set to zero
00112 
00113         void set_esc(escape *esc_ptr) { if(esc_ptr != NULL) esc = esc_ptr; else throw SRC_BUG; };
00114         void copy_from(const escape_catalogue & ref);
00115         void destroy();
00116         void merge_cat_det();
00117         void reset_reading_process();
00118     };
00119 
00121 
00122 } // end of namespace
00123 
00124 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines