Disk ARchive  2.4.10
 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 
25 
26 
27 #ifndef ARCHIVE_HPP
28 #define ARCHIVE_HPP
29 
30 #include "../my_config.h"
31 
32 #include "erreurs.hpp"
33 #include "path.hpp"
34 #include "scrambler.hpp"
35 #include "statistics.hpp"
36 #include "archive_options.hpp"
37 #include "escape.hpp"
38 #include "escape_catalogue.hpp"
39 #include "pile.hpp"
40 
41 namespace libdar
42 {
43 
45 
50  class archive
51  {
52  public:
53 
55 
62  archive(user_interaction & dialog,
63  const path & chem,
64  const std::string & basename,
65  const std::string & extension,
66  const archive_options_read & options);
67 
68 
70 
89  archive(user_interaction & dialog,
90  const path & fs_root,
91  const path & sauv_path,
92  const std::string & filename,
93  const std::string & extension,
94  const archive_options_create & options,
95  statistics * progressive_report);
96 
97 
99 
106  archive(user_interaction & dialog,
107  const path &sauv_path,
108  archive *ref_arch,
109  const std::string & filename,
110  const std::string & extension,
111  const archive_options_isolate & options);
112 
113 
115 
130 
131  archive(user_interaction & dialog,
132  const path & sauv_path,
133  archive *ref_arch1,
134  const std::string & filename,
135  const std::string & extension,
136  const archive_options_merge & options,
137  statistics * progressive_report);
138 
140 
145 
146  archive(const archive & ref) : stack(ref.stack) { throw Efeature(dar_gettext("Archive copy constructor is not implemented")); };
147  archive & operator = (const archive & ref) { throw Efeature(dar_gettext("Archive assignment operator is not implemented")); };
148 
150  ~archive() { free(); };
151 
152 
154 
174  const path &fs_root,
175  const archive_options_extract & options,
176  statistics *progressive_report);
177 
179 
180  void summary(user_interaction & dialog);
181 
182 
184 
187  void op_listing(user_interaction & dialog,
188  const archive_options_listing & options);
189 
191 
206  const path & fs_root,
207  const archive_options_diff & options,
208  statistics * progressive_report);
209 
210 
212 
233  const archive_options_test & options,
234  statistics * progressive_report);
235 
236 
238 
246  bool get_children_of(user_interaction & dialog,
247  const std::string & dir);
248 
250  const entree_stats get_stats() const { if(cat == NULL) throw SRC_BUG; return cat->get_stats(); };
251 
253 
260  const catalogue & get_catalogue() const;
261 
263  const catalogue & get_catalogue(user_interaction & dialog) const;
264 
266 
273 
275 
277 
278  private:
279  enum operation { oper_create, oper_isolate, oper_merge };
280 
281  pile stack;
282  header_version ver;
283  catalogue *cat;
284  infinint local_cat_size;
285  path *local_path;
286  bool exploitable; //< is false if only the catalogue is available (for reference backup or isolation).
287  bool lax_read_mode; //< whether the archive has been openned in lax mode (unused for creation/merging/isolation)
288  bool sequential_read; //< whether the archive is read in sequential mode
289 
290  void free();
291  catalogue & get_cat() { if(cat == NULL) throw SRC_BUG; else return *cat; };
292  const header_version & get_header() const { return ver; };
293  const path & get_path() { if(local_path == NULL) throw SRC_BUG; else return *local_path; };
294 
295  bool get_sar_param(infinint & sub_file_size, infinint & first_file_size, infinint & last_file_size,
296  infinint & total_file_number);
297  infinint get_level2_size();
298  infinint get_cat_size() const { return local_cat_size; };
299 
300  statistics op_create_in(user_interaction & dialog,
301  operation op,
302  const path & fs_root,
303  const path & sauv_path,
304  archive *ref_arch,
305  const mask & selection,
306  const mask & subtree,
307  const std::string & filename,
308  const std::string & extension,
309  bool allow_over,
310  bool warn_over,
311  bool info_details,
312  const infinint & pause,
313  bool empty_dir,
314  compression algo,
315  U_I compression_level,
316  const infinint & file_size,
317  const infinint & first_file_size,
318  const mask & ea_mask,
319  const std::string & execute,
320  crypto_algo crypto,
321  const secu_string & pass,
322  U_32 crypto_size,
323  const mask & compr_mask,
324  const infinint & min_compr_size,
325  bool nodump,
326  const infinint & hourshift,
327  bool empty,
328  bool alter_atime,
329  bool furtive_read_mode,
330  bool same_fs,
331  inode::comparison_fields what_to_check,
332  bool snapshot,
333  bool cache_directory_tagging,
334  bool display_skipped,
335  const infinint & fixed_date,
336  const std::string & slice_permission,
337  const std::string & slice_user_ownership,
338  const std::string & slice_group_ownership,
339  const infinint & repeat_count,
340  const infinint & repeat_byte,
341  bool add_marks_for_sequential_reading,
342  bool security_check,
343  const infinint & sparse_file_min_size,
344  const std::string & user_comment,
345  hash_algo hash,
346  const infinint & slice_min_digits,
347  const std::string & backup_hook_file_execute,
348  const mask & backup_hook_file_mask,
349  bool ignore_unknown,
350  statistics * progressive_report);
351 
352  void op_create_in_sub(user_interaction & dialog, //< interaction with user
353  operation op, //< the filter operation to bind to
354  const path & fs_root, //< root of the filesystem to act on
355  const path & sauv_path_t, //< where to create the archive
356  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)
357  catalogue * ref_arch2, //< secondary catalogue used for merging, can be NULL if not used
358  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)
359  const mask & selection, //< filter on filenames
360  const mask & subtree, //< filter on directory tree and filenames
361  const std::string & filename, //< basename of the archive to create
362  const std::string & extension, //< extension of the archives
363  bool allow_over, //< whether to allow overwriting (of slices)
364  const crit_action & overwrite, //< whether and how to allow overwriting (for files inside the archive)
365  bool warn_over, //< whether to warn before overwriting
366  bool info_details, //< whether to display detailed informations
367  const infinint & pause, //< whether to pause between slices
368  bool empty_dir, //< whether to store excluded dir as empty directories
369  compression algo, //< compression algorithm
370  U_I compression_level, //< compression level (range 1 to 9)
371  const infinint & file_size, //< slice size
372  const infinint & first_file_size, //< first slice size
373  const mask & ea_mask, //< Extended Attribute to consider
374  const std::string & execute, //< Command line to execute between slices
375  crypto_algo crypto, //< crypt algorithm
376  const secu_string & pass, //< password ("" for onfly request of password)
377  U_32 crypto_size, //< size of crypto blocks
378  const mask & compr_mask, //< files to compress
379  const infinint & min_compr_size, //< file size under which to not compress files
380  bool nodump, //< whether to consider the "nodump" filesystem flag
381  const infinint & hourshift, //< hourshift (see man page -H option)
382  bool empty, //< whether to make an "dry-run" execution
383  bool alter_atime, //< whether to alter atime date (by opposition to ctime) when reading files
384  bool furtive_read_mode, //< whether to neither alter atime nor ctome (if true alter_atime is ignored)
385  bool same_fs, //< confin the files consideration to a single filesystem
386  inode::comparison_fields what_to_check, //< fields to consider wien comparing inodes (see inode::comparison_fields enumeration)
387  bool snapshot, //< make as if all file had not changed
388  bool cache_directory_tagging, //< avoid saving directory which follow the cache directory tagging
389  bool display_skipped, //< display skipped files for the operation
390  bool keep_compressed, //< keep file compressed when merging
391  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
392  const std::string & slice_permission, //< permissions of slices that will be created
393  const std::string & slice_user_ownership, //< user ownership of slices that will be created
394  const std::string & slice_group_ownership, //< group ownership of slices that will be created
395  const infinint & repeat_count, //< max number of retry to save a file that have changed while it was read for backup
396  const infinint & repeat_byte, //< max amount of wasted data used to save a file that have changed while it was read for backup
397  bool decremental, //< in the merging context only, whether to build a decremental backup from the two archives of reference
398  bool add_marks_for_sequential_reading, //< whether to add marks for sequential reading
399  bool security_check, //< whether to check for ctime change with no reason (rootkit ?)
400  const infinint & sparse_file_min_size, //< starting which size to consider looking for holes in sparse files (0 for no detection)
401  const std::string & user_comment, //< user comment to put in the archive
402  hash_algo hash, //< whether to produce hash file, and which algo to use
403  const infinint & slice_min_digits, //< minimum digit for slice number
404  const std::string & backup_hook_file_execute, //< command to execute before and after files to backup
405  const mask & backup_hook_file_mask, //< files elected to have a command executed before and after their backup
406  bool ignore_unknown, //< whether to warn when an unknown inode type is met
407  statistics * st_ptr); //< statistics must not be NULL !
408 
409  void disable_natural_destruction();
410  void enable_natural_destruction();
411  const label & get_layer1_data_name() const;
412  const label & get_catalogue_data_name() const;
413  bool only_contains_an_isolated_catalogue() const; //< true if the current archive only contains an isolated catalogue
414  void check_against_isolation(user_interaction & dialog, bool lax) const; //< throw Erange exception if the archive only contains an isolated catalogue
415  void check_header_version() const;
416  };
417 
418 } // end of namespace
419 
420 #endif
statistics op_extract(user_interaction &dialog, 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)
the catalogue class which gather all objects contained in a give archive
Definition: catalogue.hpp:972
holds the statistics contents of a catalogue
Definition: catalogue.hpp:70
statistics op_diff(user_interaction &dialog, const path &fs_root, const archive_options_diff &options, statistics *progressive_report)
archive comparison with filesystem
const char * dar_gettext(const char *)
a routine to change NLS domaine forth and back for inline routines
class holding optional parameters used to test the structure coherence of an existing archive ...
archive(const archive &ref)
copy constructor (not implemented, throw an exception if called explicitely or implicitely) ...
Definition: archive.hpp:146
class pile definition. Used to manage a stack of generic_file objects
const entree_stats get_stats() const
retrieving statistics about archive contents
Definition: archive.hpp:250
This is a pure virtual class that is used by libdar when interaction with the user is required...
comparison_fields
flag used to only consider certain fields when comparing/restoring inodes
Definition: catalogue.hpp:208
the archive class realizes the most general operations on archives
Definition: archive.hpp:50
crypto_algo
the different cypher available for encryption (strong or weak)
Definition: crypto.hpp:50
here is the definition of the path classthe path class handle path and provide several operation on t...
class escape_catalogue definition. Used for sequential writing to archives, as well as several other ...
exception used when a requested feature is not (yet) implemented
Definition: erreurs.hpp:199
handle the statistic structure that gives a summary of treated files after each operatio ...
class escape definition, used for sequential reading of archivesThe class escape is used to insert es...
archive(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 &quot;read&quot; constructor] ...
void summary(user_interaction &dialog)
display a summary of the archive
class holding optional parameters used to extract files from an existing archive
contains all the excetion class thrown by libdar
compression
the different compression algorithm available
Definition: compressor.hpp:43
this file contains a set of classes used to transmit options to archive operation ...
bool nodump()
returns whether nodump flag support has been activated at compilation time
void drop_all_filedescriptors()
closes all filedescriptors and associated data, just keep the catalogue
~archive()
the destructor
Definition: archive.hpp:150
void op_listing(user_interaction &dialog, const archive_options_listing &options)
listing of the archive contents
contains the definition of the scrambler class, a very weak encryption scheme
class holding optional parameters used to list the contents of an existing archive ...
class holding optional parameters used to read an existing archive
class holding optional parameters used to proceed to the merge operation
statistics op_test(user_interaction &dialog, const archive_options_test &options, statistics *progressive_report)
test the archive integrity
class holding optional parameters used to create an archive
class holding optional parameters used to isolate an existing archive
bool get_children_of(user_interaction &dialog, const std::string &dir)
getting information about a given directory
structure returned by libdar call to give a summary of the operation done in term of file treated ...
Definition: statistics.hpp:68
the class path is here to manipulate paths in the Unix notation: using&#39;/&#39;
Definition: path.hpp:50