Disk ARchive  2.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
archive.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: archive.hpp,v 1.69 2011/04/02 20:14:26 edrusb Rel $
22 //
23 /*********************************************************************/
24 //
25 
29 
30 
31 #ifndef ARCHIVE_HPP
32 #define ARCHIVE_HPP
33 
34 #include "../my_config.h"
35 
36 #include "path.hpp"
37 #include "scrambler.hpp"
38 #include "statistics.hpp"
39 #include "archive_options.hpp"
40 #include "escape.hpp"
41 #include "escape_catalogue.hpp"
42 #include "pile.hpp"
43 
44 namespace libdar
45 {
46 
48 
53  class archive
54  {
55  public:
56 
58 
65  archive(user_interaction & dialog,
66  const path & chem,
67  const std::string & basename,
68  const std::string & extension,
69  const archive_options_read & options);
70 
71 
73 
92  archive(user_interaction & dialog,
93  const path & fs_root,
94  const path & sauv_path,
95  const std::string & filename,
96  const std::string & extension,
97  const archive_options_create & options,
98  statistics * progressive_report);
99 
100 
102 
109  archive(user_interaction & dialog,
110  const path &sauv_path,
111  archive *ref_arch,
112  const std::string & filename,
113  const std::string & extension,
114  const archive_options_isolate & options);
115 
116 
118 
133 
134  archive(user_interaction & dialog,
135  const path & sauv_path,
136  archive *ref_arch1,
137  const std::string & filename,
138  const std::string & extension,
139  const archive_options_merge & options,
140  statistics * progressive_report);
141 
143 
148 
149  archive(const archive & ref) : stack(ref.stack) { throw Efeature(gettext("Archive copy constructor is not implemented")); };
150  archive & operator = (const archive & ref) { throw Efeature(gettext("Archive assignment operator is not implemented")); };
151 
153  ~archive() { free(); };
154 
155 
157 
177  const path &fs_root,
178  const archive_options_extract & options,
179  statistics *progressive_report);
180 
182 
183  void summary(user_interaction & dialog);
184 
185 
187 
190  void op_listing(user_interaction & dialog,
191  const archive_options_listing & options);
192 
194 
209  const path & fs_root,
210  const archive_options_diff & options,
211  statistics * progressive_report);
212 
213 
215 
236  const archive_options_test & options,
237  statistics * progressive_report);
238 
239 
241 
249  bool get_children_of(user_interaction & dialog,
250  const std::string & dir);
251 
253  const entree_stats get_stats() const { if(cat == NULL) throw SRC_BUG; return cat->get_stats(); };
254 
256 
263  const catalogue & get_catalogue() const;
264 
266  const catalogue & get_catalogue(user_interaction & dialog) const;
267 
269 
276 
278 
280 
281  private:
282  enum operation { oper_create, oper_isolate, oper_merge };
283 
284  pile stack;
285  header_version ver;
286  catalogue *cat;
287  infinint local_cat_size;
288  path *local_path;
289  bool exploitable; //< is false if only the catalogue is available (for reference backup or isolation).
290  bool lax_read_mode; //< whether the archive has been openned in lax mode (unused for creation/merging/isolation)
291  bool sequential_read; //< whether the archive is read in sequential mode
292 
293  void free();
294  catalogue & get_cat() { if(cat == NULL) throw SRC_BUG; else return *cat; };
295  const header_version & get_header() const { return ver; };
296  const path & get_path() { if(local_path == NULL) throw SRC_BUG; else return *local_path; };
297 
298  bool get_sar_param(infinint & sub_file_size, infinint & first_file_size, infinint & last_file_size,
299  infinint & total_file_number);
300  infinint get_level2_size();
301  infinint get_cat_size() const { return local_cat_size; };
302 
303  statistics op_create_in(user_interaction & dialog,
304  operation op,
305  const path & fs_root,
306  const path & sauv_path,
307  archive *ref_arch,
308  const mask & selection,
309  const mask & subtree,
310  const std::string & filename,
311  const std::string & extension,
312  bool allow_over,
313  bool warn_over,
314  bool info_details,
315  const infinint & pause,
316  bool empty_dir,
317  compression algo,
318  U_I compression_level,
319  const infinint & file_size,
320  const infinint & first_file_size,
321  const mask & ea_mask,
322  const std::string & execute,
323  crypto_algo crypto,
324  const secu_string & pass,
325  U_32 crypto_size,
326  const mask & compr_mask,
327  const infinint & min_compr_size,
328  bool nodump,
329  const infinint & hourshift,
330  bool empty,
331  bool alter_atime,
332  bool furtive_read_mode,
333  bool same_fs,
334  inode::comparison_fields what_to_check,
335  bool snapshot,
336  bool cache_directory_tagging,
337  bool display_skipped,
338  const infinint & fixed_date,
339  const std::string & slice_permission,
340  const std::string & slice_user_ownership,
341  const std::string & slice_group_ownership,
342  const infinint & repeat_count,
343  const infinint & repeat_byte,
344  bool add_marks_for_sequential_reading,
345  bool security_check,
346  const infinint & sparse_file_min_size,
347  const std::string & user_comment,
348  hash_algo hash,
349  const infinint & slice_min_digits,
350  const std::string & backup_hook_file_execute,
351  const mask & backup_hook_file_mask,
352  bool ignore_unknown,
353  statistics * progressive_report);
354 
355  void op_create_in_sub(user_interaction & dialog, //< interaction with user
356  operation op, //< the filter operation to bind to
357  const path & fs_root, //< root of the filesystem to act on
358  const path & sauv_path_t, //< where to create the archive
359  catalogue * ref_arch1, //< catalogue of the archive of reference (a catalogue must be provided in any case, a empty one shall fit for no reference)
360  catalogue * ref_arch2, //< secondary catalogue used for merging, can be NULL if not used
361  const path * ref_path, //< path of the archive of archive of reference (NULL if there is no archive of reference used, thus ref_arch (previous arg) is probably an empty archive)
362  const mask & selection, //< filter on filenames
363  const mask & subtree, //< filter on directory tree and filenames
364  const std::string & filename, //< basename of the archive to create
365  const std::string & extension, //< extension of the archives
366  bool allow_over, //< whether to allow overwriting (of slices)
367  const crit_action & overwrite, //< whether and how to allow overwriting (for files inside the archive)
368  bool warn_over, //< whether to warn before overwriting
369  bool info_details, //< whether to display detailed informations
370  const infinint & pause, //< whether to pause between slices
371  bool empty_dir, //< whether to store excluded dir as empty directories
372  compression algo, //< compression algorithm
373  U_I compression_level, //< compression level (range 1 to 9)
374  const infinint & file_size, //< slice size
375  const infinint & first_file_size, //< first slice size
376  const mask & ea_mask, //< Extended Attribute to consider
377  const std::string & execute, //< Command line to execute between slices
378  crypto_algo crypto, //< crypt algorithm
379  const secu_string & pass, //< password ("" for onfly request of password)
380  U_32 crypto_size, //< size of crypto blocks
381  const mask & compr_mask, //< files to compress
382  const infinint & min_compr_size, //< file size under which to not compress files
383  bool nodump, //< whether to consider the "nodump" filesystem flag
384  const infinint & hourshift, //< hourshift (see man page -H option)
385  bool empty, //< whether to make an "dry-run" execution
386  bool alter_atime, //< whether to alter atime date (by opposition to ctime) when reading files
387  bool furtive_read_mode, //< whether to neither alter atime nor ctome (if true alter_atime is ignored)
388  bool same_fs, //< confin the files consideration to a single filesystem
389  inode::comparison_fields what_to_check, //< fields to consider wien comparing inodes (see inode::comparison_fields enumeration)
390  bool snapshot, //< make as if all file had not changed
391  bool cache_directory_tagging, //< avoid saving directory which follow the cache directory tagging
392  bool display_skipped, //< display skipped files for the operation
393  bool keep_compressed, //< keep file compressed when merging
394  const infinint & fixed_date, //< whether to ignore any archive of reference and only save file which modification is more recent that the given "fixed_date" date
395  const std::string & slice_permission, //< permissions of slices that will be created
396  const std::string & slice_user_ownership, //< user ownership of slices that will be created
397  const std::string & slice_group_ownership, //< group ownership of slices that will be created
398  const infinint & repeat_count, //< max number of retry to save a file that have changed while it was read for backup
399  const infinint & repeat_byte, //< max amount of wasted data used to save a file that have changed while it was read for backup
400  bool decremental, //< in the merging context only, whether to build a decremental backup from the two archives of reference
401  bool add_marks_for_sequential_reading, //< whether to add marks for sequential reading
402  bool security_check, //< whether to check for ctime change with no reason (rootkit ?)
403  const infinint & sparse_file_min_size, //< starting which size to consider looking for holes in sparse files (0 for no detection)
404  const std::string & user_comment, //< user comment to put in the archive
405  hash_algo hash, //< whether to produce hash file, and which algo to use
406  const infinint & slice_min_digits, //< minimum digit for slice number
407  const std::string & backup_hook_file_execute, //< command to execute before and after files to backup
408  const mask & backup_hook_file_mask, //< files elected to have a command executed before and after their backup
409  bool ignore_unknown, //< whether to warn when an unknown inode type is met
410  statistics * st_ptr); //< statistics must not be NULL !
411 
412  void disable_natural_destruction();
413  void enable_natural_destruction();
414  const label & get_layer1_data_name() const;
415  const label & get_catalogue_data_name() const;
416  bool only_contains_an_isolated_catalogue() const; //< true if the current archive only contains an isolated catalogue
417  void check_against_isolation(user_interaction & dialog, bool lax) const; //< throw Erange exception if the archive only contains an isolated catalogue
418  void check_header_version() const;
419  };
420 
421 } // end of namespace
422 
423 #endif