| Disk ARchive 2.5.10 Full featured and portable backup and archiving tool

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 #include <vector>
32 #include <string>
33
34 #include "erreurs.hpp"
35 #include "path.hpp"
36 #include "scrambler.hpp"
37 #include "statistics.hpp"
38 #include "archive_options.hpp"
39 #include "escape.hpp"
40 #include "escape_catalogue.hpp"
41 #include "pile.hpp"
42 #include "list_entry.hpp"
43 #include "on_pool.hpp"
44 #include "crypto.hpp"
45 #include "slice_layout.hpp"
46
47 namespace libdar
48 {
49
51
56 class archive : public on_pool
57 {
58 public:
59
61
68 archive(user_interaction & dialog,
69 const path & chem,
70 const std::string & basename,
71 const std::string & extension,
72 const archive_options_read & options);
73
74
76
95 archive(user_interaction & dialog,
96 const path & fs_root,
97 const path & sauv_path,
98 const std::string & filename,
99 const std::string & extension,
100 const archive_options_create & options,
101 statistics * progressive_report);
102
103
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() throw(Ebug) { free_all(); };
151
152
154
173 statistics op_extract(user_interaction & dialog,
174 const path &fs_root,
175 const archive_options_extract & options,
176 statistics *progressive_report);
177
181 void summary(user_interaction & dialog);
182
183
185
194 void op_listing(user_interaction & dialog,
195 const archive_options_listing & options);
196
198
212 statistics op_diff(user_interaction & dialog,
213 const path & fs_root,
214 const archive_options_diff & options,
215 statistics * progressive_report);
216
217
219
239 statistics op_test(user_interaction & dialog,
240 const archive_options_test & options,
241 statistics * progressive_report);
242
243
245
251 void op_isolate(user_interaction & dialog,
252 const path &sauv_path,
253 const std::string & filename,
254 const std::string & extension,
255 const archive_options_isolate & options);
256
257
259
267 bool get_children_of(user_interaction & dialog,
268 const std::string & dir);
269
279 const std::vector<list_entry> get_children_in_table(const std::string & dir) const;
280
282 bool has_subdirectory(const std::string & dir) const;
283
285 const entree_stats get_stats() const { if(cat == nullptr) throw SRC_BUG; return cat->get_stats(); };
286
288 const std::list<signator> & get_signatories() const { return gnupg_signed; };
289
292 void init_catalogue(user_interaction & dialog) const;
293
295
303 const catalogue & get_catalogue() const;
304
306 const catalogue & get_catalogue(user_interaction & dialog) const;
307
309
315 void drop_all_filedescriptors();
316
318
319 void drop_all_filedescriptors(user_interaction & dialog);
320
322 void set_to_unsaved_data_and_FSA() { if(cat == nullptr) throw SRC_BUG; cat->set_to_unsaved_data_and_FSA(); };
323
330 std::string free_and_check_memory() const;
331
341 U_64 get_first_slice_header_size() const;
342
346 U_64 get_non_first_slice_header_size() const;
347
348
349 private:
350 enum operation { oper_create, oper_isolate, oper_merge };
351
352 pile stack; //< the different layer through which the archive contents is read or wrote
353 header_version ver; //< information for the archive header
354 memory_pool *pool; //< points to local_pool or inherited pool or to nullptr if no memory_pool has to be used
355 catalogue *cat; //< archive contents
356 infinint local_cat_size; //< size of the catalogue on disk
357 bool exploitable; //< is false if only the catalogue is available (for reference backup or isolation).
358 bool lax_read_mode; //< whether the archive has been openned in lax mode (unused for creation/merging/isolation)
359 bool sequential_read; //< whether the archive is read in sequential mode
360 bool freed_and_checked; //< whether free_and_check has been run
361 std::list<signator> gnupg_signed; //< list of signature found in the archive (reading an existing archive)
362 slice_layout slices; //< slice layout, archive is not sliced <=> first_size or other_size fields is set to zero (in practice both are set to zero, but one being set is enought to determine the archive is not sliced)
363
364 void free_except_memory_pool();
365 void free_all();
366 void init_pool();
367 void check_gnupg_signed(user_interaction & dialog) const;
368
369 const catalogue & get_cat() const { if(cat == nullptr) throw SRC_BUG; else return *cat; };
370 const header_version & get_header() const { return ver; };
371
372 bool get_sar_param(infinint & sub_file_size, infinint & first_file_size, infinint & last_file_size,
373 infinint & total_file_number);
374 const entrepot *get_entrepot(); //< this method may return nullptr if no entrepot is used (pipes used for archive building, etc.)
375 infinint get_level2_size();
376 infinint get_cat_size() const { return local_cat_size; };
377
378 statistics op_create_in(user_interaction & dialog,
379 operation op,
380 const path & fs_root,
381 const entrepot & sauv_path_t,
382 archive *ref_arch,
383 const mask & selection,
384 const mask & subtree,
385 const std::string & filename,
386 const std::string & extension,
387 bool allow_over,
388 bool warn_over,
389 bool info_details,
390 bool display_treated,
391 bool display_treated_only_dir,
392 bool display_skipped,
393 bool display_finished,
394 const infinint & pause,
395 bool empty_dir,
396 compression algo,
397 U_I compression_level,
398 const infinint & file_size,
399 const infinint & first_file_size,
400 const mask & ea_mask,
401 const std::string & execute,
402 crypto_algo crypto,
403 const secu_string & pass,
404 U_32 crypto_size,
405 const std::vector<std::string> & gnupg_recipients,
406 const std::vector<std::string> & gnupg_signatories,
407 const mask & compr_mask,
408 const infinint & min_compr_size,
409 bool nodump,
410 const std::string & exclude_by_ea,
411 const infinint & hourshift,
412 bool empty,
413 bool alter_atime,
414 bool furtive_read_mode,
415 bool same_fs,
416 cat_inode::comparison_fields what_to_check,
417 bool snapshot,
418 bool cache_directory_tagging,
419 const infinint & fixed_date,
420 const std::string & slice_permission,
421 const infinint & repeat_count,
422 const infinint & repeat_byte,
423 bool add_marks_for_sequential_reading,
424 bool security_check,
425 const infinint & sparse_file_min_size,
426 const std::string & user_comment,
427 hash_algo hash,
428 const infinint & slice_min_digits,
429 const std::string & backup_hook_file_execute,
430 const mask & backup_hook_file_mask,
431 bool ignore_unknown,
432 const fsa_scope & scope,
433 bool multi_threaded,
434 statistics * progressive_report);
435
436 void op_create_in_sub(user_interaction & dialog, //< interaction with user
437 operation op, //< the filter operation to bind to
438 const path & fs_root, //< root of the filesystem to act on
439 const entrepot & sauv_path_t, //< where to create the archive
440 const catalogue * ref_cat1, //< catalogue of the archive of reference, (cannot be nullptr if ref_cat2 is not nullptr)
441 const catalogue * ref_cat2, //< secondary catalogue used for merging, can be nullptr if not used
442 bool initial_pause, //< whether we shall pause before starting the archive creation
443 const mask & selection, //< filter on filenames
444 const mask & subtree, //< filter on directory tree and filenames
445 const std::string & filename, //< basename of the archive to create
446 const std::string & extension, //< extension of the archives
447 bool allow_over, //< whether to allow overwriting (of slices)
448 const crit_action & overwrite, //< whether and how to allow overwriting (for files inside the archive)
449 bool warn_over, //< whether to warn before overwriting
450 bool info_details, //< whether to display detailed informations
451 bool display_treated, //< whether to display treated files
452 bool display_treated_only_dir, //< whether to only display current directory of treated files
453 bool display_skipped, //< display skipped files for the operation
454 bool display_finished, //< display space and compression ratio summary for each completed directory
455 const infinint & pause, //< whether to pause between slices
456 bool empty_dir, //< whether to store excluded dir as empty directories
457 compression algo, //< compression algorithm
458 U_I compression_level, //< compression level (range 1 to 9)
459 const infinint & file_size, //< slice size
460 const infinint & first_file_size, //< first slice size
461 const mask & ea_mask, //< Extended Attribute to consider
462 const std::string & execute, //< Command line to execute between slices
463 crypto_algo crypto, //< crypt algorithm
464 const secu_string & pass, //< password ("" for onfly request of password)
465 U_32 crypto_size, //< size of crypto blocks
466 const std::vector<std::string> & gnupg_recipients, //< list of email recipients to encrypted a randomly chosen key inside the archive
467 const std::vector<std::string> & gnupg_signatories, //< list of email recipients to use for signature
468 const mask & compr_mask, //< files to compress
469 const infinint & min_compr_size, //< file size under which to not compress files
470 bool nodump, //< whether to consider the "nodump" filesystem flag
471 const std::string & exclude_by_ea,//< if not empty the ea to use for inode exclusion from backup operation
472 const infinint & hourshift, //< hourshift (see man page -H option)
473 bool empty, //< whether to make an "dry-run" execution
474 bool alter_atime, //< whether to alter atime date (by opposition to ctime) when reading files
475 bool furtive_read_mode, //< whether to neither alter atime nor ctome (if true alter_atime is ignored)
476 bool same_fs, //< confin the files consideration to a single filesystem
477 cat_inode::comparison_fields what_to_check, //< fields to consider wien comparing inodes (see cat_inode::comparison_fields enumeration)
478 bool snapshot, //< make as if all file had not changed
479 bool cache_directory_tagging, //< avoid saving directory which follow the cache directory tagging
480 bool keep_compressed, //< keep file compressed when merging
481 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
482 const std::string & slice_permission, //< permissions of slices that will be created
483 const infinint & repeat_count, //< max number of retry to save a file that have changed while it was read for backup
484 const infinint & repeat_byte, //< max amount of wasted data used to save a file that have changed while it was read for backup
485 bool decremental, //< in the merging context only, whether to build a decremental backup from the two archives of reference
486 bool add_marks_for_sequential_reading, //< whether to add marks for sequential reading
487 bool security_check, //< whether to check for ctime change with no reason (rootkit ?)
488 const infinint & sparse_file_min_size, //< starting which size to consider looking for holes in sparse files (0 for no detection)
489 const std::string & user_comment, //< user comment to put in the archive
490 hash_algo hash, //< whether to produce hash file, and which algo to use
491 const infinint & slice_min_digits, //< minimum digit for slice number
492 const std::string & backup_hook_file_execute, //< command to execute before and after files to backup
493 const mask & backup_hook_file_mask, //< files elected to have a command executed before and after their backup
494 bool ignore_unknown, //< whether to warn when an unknown inode type is met
495 const fsa_scope & scope, //< FSA scope for the operation
496 bool multi_threaded, //< whether libdar is allowed to spawn several thread to possibily work faster on multicore CPU
497 statistics * st_ptr); //< statistics must not be nullptr !
498
499 void disable_natural_destruction();
500 void enable_natural_destruction();
501 const label & get_layer1_data_name() const;
502 const label & get_catalogue_data_name() const;
503 bool only_contains_an_isolated_catalogue() const; //< true if the current archive only contains an isolated catalogue
504 void check_against_isolation(user_interaction & dialog, bool lax) const; //< throw Erange exception if the archive only contains an isolated catalogue
505 const cat_directory *get_dir_object(const std::string & dir) const;
506 };
507
508 } // end of namespace
509
510 #endif
libdar::on_pool
Definition: on_pool.hpp:52
libdar::archive::op_extract
statistics op_extract(user_interaction &dialog, const path &fs_root, const archive_options_extract &options, statistics *progressive_report)
extraction of data from an archive
libdar::archive::get_catalogue
const catalogue & get_catalogue() const
gives access to internal catalogue (not to be used from the API)
libdar::catalogue
the catalogue class which gather all objects contained in a give archive
Definition: catalogue.hpp:62
libdar::entree_stats
holds the statistics contents of a catalogue
Definition: cat_entree.hpp:61
libdar::archive::has_subdirectory
bool has_subdirectory(const std::string &dir) const
returns true if the pointed directory has one or more subdirectories
libdar::archive::op_diff
statistics op_diff(user_interaction &dialog, const path &fs_root, const archive_options_diff &options, statistics *progressive_report)
archive comparison with filesystem
libdar::dar_gettext
const char * dar_gettext(const char *)
a routine to change NLS domaine forth and back for inline routines
libdar::archive_options_test
class holding optional parameters used to test the structure coherence of an existing archive ...
Definition: archive_options.hpp:1343
libdar::archive::archive
archive(const archive &ref)
copy constructor (not implemented, throw an exception if called explicitely or implicitely) ...
Definition: archive.hpp:146
list_entry.hpp
class of objects describing an entry in the archive, used by archive::get_children_in_table ...
pile.hpp
class pile definition. Used to manage a stack of generic_file objects
libdar::archive::get_stats
const entree_stats get_stats() const
retrieving statistics about archive contents
Definition: archive.hpp:285
libdar::user_interaction
This is a pure virtual class that is used by libdar when interaction with the user is required...
Definition: user_interaction.hpp:98
libdar::archive::init_catalogue
void init_catalogue(user_interaction &dialog) const
crypto.hpp
the crypto algoritm definition
slice_layout.hpp
object describing the slicing of an archive
libdar::archive::get_first_slice_header_size
U_64 get_first_slice_header_size() const
libdar::archive
the archive class realizes the most general operations on archives
Definition: archive.hpp:56
libdar::crypto_algo
crypto_algo
the different cypher available for encryption (strong or weak)
Definition: crypto.hpp:51
libdar::archive::get_children_in_table
const std::vector< list_entry > get_children_in_table(const std::string &dir) const
path.hpp
here is the definition of the path classthe path class handle path and provide several operation on t...
escape_catalogue.hpp
class escape_catalogue definition. Used for sequential writing to archives, as well as several other ...
libdar::Efeature
exception used when a requested feature is not (yet) implemented
Definition: erreurs.hpp:206
statistics.hpp
handle the statistic structure that gives a summary of treated files after each operatio ...
escape.hpp
class escape definition, used for sequential reading of archivesThe class escape is used to insert es...
libdar::archive::archive
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 "read" constructor] ...
libdar::archive::summary
void summary(user_interaction &dialog)
libdar::archive::op_isolate
void op_isolate(user_interaction &dialog, 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 ...
libdar::archive_options_extract
class holding optional parameters used to extract files from an existing archive
Definition: archive_options.hpp:1028
erreurs.hpp
contains all the excetion class thrown by libdar
libdar::Ebug
exception used to signal a bug. A bug is triggered when reaching some code that should never be reach...
Definition: erreurs.hpp:137
libdar::compression
compression
the different compression algorithm available
Definition: compressor.hpp:43
archive_options.hpp
this file contains a set of classes used to transmit options to archive operation ...
libdar::compile_time::nodump
bool nodump()
returns whether nodump flag support has been activated at compilation time
libdar::archive::drop_all_filedescriptors
void drop_all_filedescriptors()
closes all filedescriptors and associated data, just keep the catalogue
libdar::archive::~archive
~archive()
the destructor
Definition: archive.hpp:150
libdar::archive::op_listing
void op_listing(user_interaction &dialog, const archive_options_listing &options)
listing of the archive contents
scrambler.hpp
contains the definition of the scrambler class, a very weak encryption scheme
on_pool.hpp
this is the base class of object that can be allocated on a memory pool
libdar::archive_options_listing
class holding optional parameters used to list the contents of an existing archive ...
Definition: archive_options.hpp:1167
libdar::hash_algo
hash_algo
Definition: hash_fichier.hpp:57
libdar::archive::free_and_check_memory
std::string free_and_check_memory() const
libdar::cat_inode::comparison_fields
comparison_fields
flag used to only consider certain fields when comparing/restoring inodes
Definition: cat_inode.hpp:60
libdar::archive::set_to_unsaved_data_and_FSA
void set_to_unsaved_data_and_FSA()
change all inode as unsaved (equal to differential backup with no change met)
Definition: archive.hpp:322
libdar::archive::get_signatories
const std::list< signator > & get_signatories() const
retrieving signature information about the archive
Definition: archive.hpp:288
libdar::archive_options_read
class holding optional parameters used to read an existing archive
Definition: archive_options.hpp:59
libdar::archive_options_merge
class holding optional parameters used to proceed to the merge operation
Definition: archive_options.hpp:788
libdar::archive::get_non_first_slice_header_size
U_64 get_non_first_slice_header_size() const
libdar::archive::op_test
statistics op_test(user_interaction &dialog, const archive_options_test &options, statistics *progressive_report)
test the archive integrity
libdar::archive_options_create
class holding optional parameters used to create an archive
Definition: archive_options.hpp:259
libdar::archive_options_isolate
class holding optional parameters used to isolate an existing archive
Definition: archive_options.hpp:626
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
libdar::archive::get_children_of
bool get_children_of(user_interaction &dialog, const std::string &dir)
getting information about a given directory
libdar::statistics
structure returned by libdar call to give a summary of the operation done in term of file treated ...
Definition: statistics.hpp:68
libdar::path
the class path is here to manipulate paths in the Unix notation: using'/'
Definition: path.hpp:50