Disk ARchive  2.4.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
escape_catalogue.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 // $Id: escape_catalogue.hpp,v 1.14.2.2 2012/02/19 22:15:05 edrusb Rel $
22 //
23 /*********************************************************************/
24 
36 
37 #ifndef ESCAPE_CATALOGUE_HPP
38 #define ESCAPE_CATALOGUE_HPP
39 
40 #include "../my_config.h"
41 
42 #include "catalogue.hpp"
43 #include "escape.hpp"
44 
45 namespace libdar
46 {
47 
50 
51  class escape_catalogue : public catalogue
52  {
53  public:
54  escape_catalogue(user_interaction & dialog,
55  const infinint & root_last_modif,
56  const label & data_name, escape *esc_ptr);
57  escape_catalogue(user_interaction & dialog, //< user interaction
58  const archive_version & reading_ver, //< archive format
59  compression default_algo, //< default compression algorithm
60  generic_file *data_loc, //< at which layer to read data from
61  generic_file *ea_loc, //< at which layer to read EA from
62  escape *esc_ptr, //< the escape layer of the stack
63  bool lax = false); //< whether to use lax mode
64  escape_catalogue(const escape_catalogue & ref) : catalogue(ref) { copy_from(ref); };
65  const escape_catalogue & operator = (const escape_catalogue &ref);
66  ~escape_catalogue() { destroy(); };
67 
68  // inherited from catalogue
69  void pre_add(const entree *ref, compressor *compr) const;
70  void pre_add_ea(const entree *ref, compressor *compr) const;
71  void pre_add_crc(const entree *ref, compressor *compr) const;
72  void pre_add_dirty(compressor *compr) const;
73  void pre_add_ea_crc(const entree *ref, compressor *compr) const;
74  void pre_add_waste_mark(compressor *compr) const;
75  void pre_add_failed_mark(compressor *compr) const;
76  escape *get_escape_layer() const { return esc; };
77 
78  void reset_read() const;
79  void end_read() const;
80  void skip_read_to_parent_dir() const;
81  bool read(const entree * & ref) const;
82  bool read_if_present(std::string *name, const nomme * & ref) const;
83  void tail_catalogue_to_current_read();
84  bool read_second_time_dir() const { return status == ec_detruits; };
85 
86  private:
87  enum state
88  {
89  ec_init, //< state in which no one file has yet been searched in the archive
90  ec_marks, //< state in which we find the next file using escape sequence marks
91  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
92  ec_detruits, //< state in which which detruits objects are returned from the catalogue
93  ec_completed //< state in which the escape_catalogue object is completed and has all information in memory as a normal catalogue
94  };
95 
96  escape *esc;
97  archive_version x_reading_ver;
98  compression x_default_algo;
99  generic_file *x_data_loc;
100  generic_file *x_ea_loc;
101  bool x_lax;
102  std::map <infinint, etoile *> corres;
103  state status;
104  catalogue *cat_det; //< holds the final catalogue's detruit objects when no more file can be read from the archive
105  infinint min_read_offset; //< next offset in archive should be greater than that to identify a mark
106  infinint depth; //< directory depth of archive being read sequentially
107  infinint wait_parent_depth; //< ignore any further entry while depth is less than wait_parent_depth. disabled is set to zero
108 
109  void set_esc(escape *esc_ptr) { if(esc_ptr != NULL) esc = esc_ptr; else throw SRC_BUG; };
110  void copy_from(const escape_catalogue & ref);
111  void destroy();
112  void merge_cat_det();
113  void reset_reading_process();
114  };
115 
117 
118 } // end of namespace
119 
120 #endif