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