Disk ARchive  2.6.0
Full featured and portable backup and archiving tool
i_archive.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2018 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 
25 
26 
27 #ifndef I_ARCHIVE_HPP
28 #define I_ARCHIVE_HPP
29 
30 #include "../my_config.h"
31 #include <vector>
32 #include <string>
33 #include <memory>
34 
35 #include "erreurs.hpp"
36 #include "path.hpp"
37 #include "statistics.hpp"
38 #include "archive_options.hpp"
39 #include "pile.hpp"
40 #include "list_entry.hpp"
41 #include "crypto.hpp"
42 #include "slice_layout.hpp"
43 #include "mem_ui.hpp"
44 #include "archive_summary.hpp"
46 #include "catalogue.hpp"
47 #include "archive.hpp"
48 #include "header_version.hpp"
49 
50 namespace libdar
51 {
52 
55 
57 
58  class archive::i_archive: public mem_ui
59  {
60  public:
61 
63 
64  i_archive(const std::shared_ptr<user_interaction> & dialog,
65  const path & chem,
66  const std::string & basename,
67  const std::string & extension,
68  const archive_options_read & options);
69 
70 
72 
73  i_archive(const std::shared_ptr<user_interaction> & dialog,
74  const path & fs_root,
75  const path & sauv_path,
76  const std::string & filename,
77  const std::string & extension,
78  const archive_options_create & options,
79  statistics * progressive_report);
80 
82 
83  i_archive(const std::shared_ptr<user_interaction> & dialog,
84  const path & sauv_path,
85  std::shared_ptr<archive> ref_arch1,
86  const std::string & filename,
87  const std::string & extension,
88  const archive_options_merge & options,
89  statistics * progressive_report);
90 
92 
93  i_archive(const std::shared_ptr<user_interaction> & dialog,
94  const path & chem_src,
95  const std::string & basename_src,
96  const std::string & extension_src,
97  const archive_options_read & options_read,
98  const path & chem_dst,
99  const std::string & basename_dst,
100  const std::string & extension_dst,
101  const archive_options_repair & options_repair);
102 
104 
105  i_archive(const i_archive & ref) = delete;
106  i_archive(i_archive && ref) = delete;
107  i_archive & operator = (const i_archive & ref) = delete;
108  i_archive & operator = (i_archive && ref) = delete;
109 
111 
112  ~i_archive() { free_mem(); };
113 
114 
116 
117  statistics op_extract(const path &fs_root,
118  const archive_options_extract & options,
119  statistics *progressive_report);
120 
122 
123  void summary();
124 
127 
128 
130 
131  void op_listing(archive_listing_callback callback,
132  void *context,
133  const archive_options_listing & options) const;
134 
136 
137  statistics op_diff(const path & fs_root,
138  const archive_options_diff & options,
139  statistics * progressive_report);
140 
141 
143 
144  statistics op_test(const archive_options_test & options,
145  statistics * progressive_report);
146 
147 
149 
150  void op_isolate(const path &sauv_path,
151  const std::string & filename,
152  const std::string & extension,
153  const archive_options_isolate & options);
154 
155 
157 
159  void *context,
160  const std::string & dir,
161  bool fetch_ea = false);
162 
164 
165  const std::vector<list_entry> get_children_in_table(const std::string & dir, bool fetch_ea = false) const;
166 
168  bool has_subdirectory(const std::string & dir) const;
169 
171  const entree_stats get_stats() const { if(cat == nullptr) throw SRC_BUG; return cat->get_stats(); };
172 
174  const std::list<signator> & get_signatories() const { return gnupg_signed; };
175 
178  void init_catalogue() const;
179 
181 
182  const catalogue & get_catalogue() const;
183 
185 
187 
189  void set_to_unsaved_data_and_FSA() { if(cat == nullptr) throw SRC_BUG; cat->set_to_unsaved_data_and_FSA(); };
190 
192 
193  bool get_catalogue_slice_layout(slice_layout & slicing) const;
194 
196 
197  U_64 get_first_slice_header_size() const;
198 
200 
201  U_64 get_non_first_slice_header_size() const;
202 
203 
204  private:
205  enum operation { oper_create, oper_isolate, oper_merge, oper_repair };
206 
211  bool exploitable;
214  std::list<signator> gnupg_signed;
215  slice_layout slices;
216 
217  void free_mem();
218  void check_gnupg_signed() const;
219 
220  const catalogue & get_cat() const { if(cat == nullptr) throw SRC_BUG; else return *cat; };
221  const header_version & get_header() const { return ver; };
222 
223  bool get_sar_param(infinint & sub_file_size, infinint & first_file_size, infinint & last_file_size,
224  infinint & total_file_number);
225  std::shared_ptr<entrepot> get_entrepot();
226  infinint get_level2_size();
227  infinint get_cat_size() const { return local_cat_size; };
228 
229  statistics op_create_in(operation op,
230  const path & fs_root,
231  const std::shared_ptr<entrepot> & sauv_path_t,
232  archive *ref_arch,
233  const mask & selection,
234  const mask & subtree,
235  const std::string & filename,
236  const std::string & extension,
237  bool allow_over,
238  bool warn_over,
239  bool info_details,
240  bool display_treated,
241  bool display_treated_only_dir,
242  bool display_skipped,
243  bool display_finished,
244  const infinint & pause,
245  bool empty_dir,
246  compression algo,
247  U_I compression_level,
248  const infinint & file_size,
249  const infinint & first_file_size,
250  const mask & ea_mask,
251  const std::string & execute,
252  crypto_algo crypto,
253  const secu_string & pass,
254  U_32 crypto_size,
255  const std::vector<std::string> & gnupg_recipients,
256  const std::vector<std::string> & gnupg_signatories,
257  const mask & compr_mask,
258  const infinint & min_compr_size,
259  bool nodump,
260  const std::string & exclude_by_ea,
261  const infinint & hourshift,
262  bool empty,
263  bool alter_atime,
264  bool furtive_read_mode,
265  bool same_fs,
266  comparison_fields what_to_check,
267  bool snapshot,
268  bool cache_directory_tagging,
269  const infinint & fixed_date,
270  const std::string & slice_permission,
271  const infinint & repeat_count,
272  const infinint & repeat_byte,
273  bool add_marks_for_sequential_reading,
274  bool security_check,
275  const infinint & sparse_file_min_size,
276  const std::string & user_comment,
277  hash_algo hash,
278  const infinint & slice_min_digits,
279  const std::string & backup_hook_file_execute,
280  const mask & backup_hook_file_mask,
281  bool ignore_unknown,
282  const fsa_scope & scope,
283  bool multi_threaded,
284  bool delta_signature,
285  bool build_delta_sig,
286  const mask & delta_mask,
287  const infinint & delta_sig_min_size,
288  bool delta_diff,
289  bool zeroing_neg_date,
290  const std::set<std::string> & ignored_symlinks,
291  modified_data_detection mod_data_detect,
292  const infinint & iteration_count,
293  hash_algo kdf_hash,
294  statistics * progressive_report);
295 
296  void op_create_in_sub(operation op,
297  const path & fs_root,
298  const std::shared_ptr<entrepot> & sauv_path_t,
299  catalogue * ref_cat1,
300  const catalogue * ref_cat2,
301  bool initial_pause,
302  const mask & selection,
303  const mask & subtree,
304  const std::string & filename,
305  const std::string & extension,
306  bool allow_over,
307  const crit_action & overwrite,
308  bool warn_over,
309  bool info_details,
310  bool display_treated,
311  bool display_treated_only_dir,
312  bool display_skipped,
313  bool display_finished,
314  const infinint & pause,
315  bool empty_dir,
316  compression algo,
317  U_I compression_level,
318  const infinint & file_size,
319  const infinint & first_file_size,
320  const mask & ea_mask,
321  const std::string & execute,
322  crypto_algo crypto,
323  const secu_string & pass,
324  U_32 crypto_size,
325  const std::vector<std::string> & gnupg_recipients,
326  const std::vector<std::string> & gnupg_signatories,
327  const mask & compr_mask,
328  const infinint & min_compr_size,
329  bool nodump,
330  const std::string & exclude_by_ea,
331  const infinint & hourshift,
332  bool empty,
333  bool alter_atime,
334  bool furtive_read_mode,
335  bool same_fs,
336  comparison_fields what_to_check,
337  bool snapshot,
338  bool cache_directory_tagging,
339  bool keep_compressed,
340  const infinint & fixed_date,
341  const std::string & slice_permission,
342  const infinint & repeat_count,
343  const infinint & repeat_byte,
344  bool decremental,
345  bool add_marks_for_sequential_reading,
346  bool security_check,
347  const infinint & sparse_file_min_size,
348  const std::string & user_comment,
349  hash_algo hash,
350  const infinint & slice_min_digits,
351  const std::string & backup_hook_file_execute,
352  const mask & backup_hook_file_mask,
353  bool ignore_unknown,
354  const fsa_scope & scope,
355  bool multi_threaded,
356  bool delta_signature,
357  bool build_delta_sig,
358  const mask & delta_mask,
359  const infinint & delta_sig_min_size,
360  bool delta_diff,
361  bool zeroing_neg_date,
362  const std::set<std::string> & ignored_symlinks,
363  modified_data_detection mod_data_detect,
364  const infinint & iteration_count,
365  hash_algo kdf_hash,
366  statistics * st_ptr
367  );
368 
369  void disable_natural_destruction();
370  void enable_natural_destruction();
371  const label & get_layer1_data_name() const;
372  const label & get_catalogue_data_name() const;
374  void check_against_isolation(bool lax) const;
375  const cat_directory *get_dir_object(const std::string & dir) const;
376  void load_catalogue();
377  };
378 
379 } // end of namespace
380 
381 #endif
comparison_fields
how to consider file change during comparison and incremental backup
Definition: archive_aux.hpp:52
statistics op_diff(const path &fs_root, const archive_options_diff &options, statistics *progressive_report)
archive comparison with filesystem
statistics op_extract(const path &fs_root, const archive_options_extract &options, statistics *progressive_report)
extraction of data from an archive
const catalogue & get_catalogue() const
gives access to internal catalogue (not to be used from the API)
header_version ver
information for the archive header
Definition: i_archive.hpp:208
the generic class, parent of all masks
Definition: mask.hpp:61
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
statistics op_test(const archive_options_test &options, statistics *progressive_report)
test the archive integrity
the archive class is defined in this module
the catalogue class which gather all objects contained in a give archive
Definition: catalogue.hpp:59
holds the statistics contents of a catalogue
bool get_children_of(archive_listing_callback callback, void *context, const std::string &dir, bool fetch_ea=false)
getting information about a given directory
void set_to_unsaved_data_and_FSA()
change all inode as unsaved (equal to differential backup with no change met)
Definition: i_archive.hpp:189
bool sequential_read
whether the archive is read in sequential mode
Definition: i_archive.hpp:213
void drop_all_filedescriptors()
closes all filedescriptors and associated even when in sequential read mode
class holding optional parameters used to test the structure coherence of an existing archive ...
bool exploitable
is false if only the catalogue is available (for reference backup or isolation).
Definition: i_archive.hpp:211
void summary()
display a summary of the archive
class of objects describing an entry in the archive, used by archive::get_children_in_table ...
class pile definition. Used to manage a stack of generic_file objects
bool get_catalogue_slice_layout(slice_layout &slicing) const
returns the slice layout of the archive, or of the archive of reference in case of isolated catalogue...
bool only_contains_an_isolated_catalogue() const
true if the current archive only contains an isolated catalogue
manages the archive header and trailer
the crypto algoritm definition
std::shared_ptr< entrepot > get_entrepot()
this method may return nullptr if no entrepot is used (pipes used for archive building, etc.)
object describing the slicing of an archive
the cat_directory inode class
~i_archive()
the destructor
Definition: i_archive.hpp:112
the archive::i_archive class implements the most general operations on archives
Definition: i_archive.hpp:58
the archive class realizes the most general operations on archives
Definition: archive.hpp:64
archive global header/trailer structure is defined here
const std::vector< list_entry > get_children_in_table(const std::string &dir, bool fetch_ea=false) const
getting information about the given directory (alternative to get_children_of)
crypto_algo
the different cypher available for encryption (strong or weak)
Definition: crypto.hpp:49
here is the definition of the path classthe path class handle path and provide several operation on t...
definition of the user defined callback function used for archive listing
class handling access to the data summary of treated files after and during each operation ...
stores a stack of generic_files writing/reading on each others
Definition: pile.hpp:43
U_64 get_first_slice_header_size() const
get the first slice header
the global action for overwriting
Definition: crit_action.hpp:81
std::list< signator > gnupg_signed
list of signature found in the archive (reading an existing archive)
Definition: i_archive.hpp:214
class holding optional parameters used to extract files from an existing archive
const std::list< signator > & get_signatories() const
retrieving signature information about the archive
Definition: i_archive.hpp:174
slice_layout slices
slice layout, archive is not sliced <=> first_size or other_size fields is set to zero (in practice b...
Definition: i_archive.hpp:215
contains all the excetion class thrown by libdar
const entree_stats get_stats() const
retrieving statistics about archive contents
Definition: i_archive.hpp:171
std::set< fsa_family > fsa_scope
set of fsa families
Definition: fsa_family.hpp:70
void op_isolate(const path &sauv_path, const std::string &filename, const std::string &extension, const archive_options_isolate &options)
this methodes isolates the catalogue of a the current archive into a separated archive ...
pile stack
the different layer through which the archive contents is read or wrote
Definition: i_archive.hpp:207
modified_data_detection
how to detect data has changed when some fields
Definition: archive_aux.hpp:43
class secu_string
Definition: secu_string.hpp:57
compression
the different compression algorithm available
Definition: compression.hpp:45
this file contains a set of classes used to transmit options to archive operation ...
class mem_ui to keep a copy of a user_interaction object
Definition: mem_ui.hpp:54
class holding optional parameters used to create an archive
manage label data structure used in archive slice headers
Definition: label.hpp:42
U_64 get_non_first_slice_header_size() const
get the non first slice header
class holding optional parameters used to list the contents of an existing archive ...
hash_algo
hashing algorithm available
Definition: archive_aux.hpp:62
infinint local_cat_size
size of the catalogue on disk
Definition: i_archive.hpp:210
the arbitrary large positive integer class
void(*)(const std::string &the_path, const list_entry &entry, void *context) archive_listing_callback
callback function type expected for archive::op_listing and archive::get_children_of() ...
bool has_subdirectory(const std::string &dir) const
returns true if the pointed directory has one or more subdirectories
void op_listing(archive_listing_callback callback, void *context, const archive_options_listing &options) const
listing of the archive contents
class holding optional parameters used to read an existing archive
void op_create_in_sub(operation op, const path &fs_root, const std::shared_ptr< entrepot > &sauv_path_t, catalogue *ref_cat1, const catalogue *ref_cat2, bool initial_pause, const mask &selection, const mask &subtree, const std::string &filename, const std::string &extension, bool allow_over, const crit_action &overwrite, bool warn_over, bool info_details, bool display_treated, bool display_treated_only_dir, bool display_skipped, bool display_finished, const infinint &pause, bool empty_dir, compression algo, U_I compression_level, const infinint &file_size, const infinint &first_file_size, const mask &ea_mask, const std::string &execute, crypto_algo crypto, const secu_string &pass, U_32 crypto_size, const std::vector< std::string > &gnupg_recipients, const std::vector< std::string > &gnupg_signatories, const mask &compr_mask, const infinint &min_compr_size, bool nodump, const std::string &exclude_by_ea, const infinint &hourshift, bool empty, bool alter_atime, bool furtive_read_mode, bool same_fs, comparison_fields what_to_check, bool snapshot, bool cache_directory_tagging, bool keep_compressed, const infinint &fixed_date, const std::string &slice_permission, const infinint &repeat_count, const infinint &repeat_byte, bool decremental, bool add_marks_for_sequential_reading, bool security_check, const infinint &sparse_file_min_size, const std::string &user_comment, hash_algo hash, const infinint &slice_min_digits, const std::string &backup_hook_file_execute, const mask &backup_hook_file_mask, bool ignore_unknown, const fsa_scope &scope, bool multi_threaded, bool delta_signature, bool build_delta_sig, const mask &delta_mask, const infinint &delta_sig_min_size, bool delta_diff, bool zeroing_neg_date, const std::set< std::string > &ignored_symlinks, modified_data_detection mod_data_detect, const infinint &iteration_count, hash_algo kdf_hash, statistics *st_ptr)
class holding optional parameters used to proceed to the merge operation
class holding optional parameters used to create an archive
void check_against_isolation(bool lax) const
throw Erange exception if the archive only contains an isolated catalogue
i_archive(const std::shared_ptr< user_interaction > &dialog, const path &chem, const std::string &basename, const std::string &extension, const archive_options_read &options)
this constructor opens an already existing archive (for reading) [this is the "read" constructor] ...
class holding optional parameters used to isolate an existing archive
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:46
archive_summary summary_data()
same information as summary() but as broken out data
here is defined the classe used to manage catalogue of archives
catalogue * cat
archive contents
Definition: i_archive.hpp:209
bool nodump() noexcept
returns whether nodump flag support has been activated at compilation time
the archive_summary class provides information about a given archive
bool lax_read_mode
whether the archive has been openned in lax mode (unused for creation/merging/isolation) ...
Definition: i_archive.hpp:212
class used by libdar::archive class to give a summary of treated file during and after an operation ...
Definition: statistics.hpp:69
datastructure returned by archive::summary_data
the class path is here to manipulate paths in the Unix notation: using&#39;/&#39;
Definition: path.hpp:49