Loading...
Searching...
No Matches
i_archive.hpp
Go to the documentation of this file.
/*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2026 Denis Corbin
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// to contact the author, see the AUTHOR file
/*********************************************************************/
#ifndef I_ARCHIVE_HPP
#define I_ARCHIVE_HPP
#include "../my_config.h"
#include <vector>
#include <string>
#include <memory>
#include "erreurs.hpp"
#include "path.hpp"
#include "statistics.hpp"
#include "archive_options.hpp"
#include "pile.hpp"
#include "list_entry.hpp"
#include "crypto.hpp"
#include "slice_layout.hpp"
#include "mem_ui.hpp"
#include "archive_summary.hpp"
#include "archive_listing_callback.hpp"
#include "catalogue.hpp"
#include "archive.hpp"
#include "header_version.hpp"
namespace libdar
{
class archive::i_archive: public mem_ui
{
public:
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);
i_archive(const std::shared_ptr<user_interaction> & dialog,
const path & fs_root,
const path & sauv_path,
const std::string & filename,
const std::string & extension,
const archive_options_create & options,
statistics * progressive_report);
i_archive(const std::shared_ptr<user_interaction> & dialog,
const path & sauv_path,
std::shared_ptr<archive> ref_arch1,
const std::string & filename,
const std::string & extension,
const archive_options_merge & options,
statistics * progressive_report);
i_archive(const std::shared_ptr<user_interaction> & dialog,
const path & chem_src,
const std::string & basename_src,
const std::string & extension_src,
const archive_options_read & options_read,
const path & chem_dst,
const std::string & basename_dst,
const std::string & extension_dst,
const archive_options_repair & options_repair,
statistics * progressive_report);
i_archive(const i_archive & ref) = delete;
i_archive(i_archive && ref) = delete;
i_archive & operator = (const i_archive & ref) = delete;
i_archive & operator = (i_archive && ref) = delete;
~i_archive() { free_mem(); };
statistics op_extract(const path &fs_root,
const archive_options_extract & options,
statistics *progressive_report);
void summary();
archive_summary summary_data();
void op_listing(archive_listing_callback callback,
void *context,
const archive_options_listing & options) const;
statistics op_diff(const path & fs_root,
const archive_options_diff & options,
statistics * progressive_report);
statistics op_test(const archive_options_test & options,
bool reparing,
statistics * progressive_report
);
void op_isolate(const path &sauv_path,
const std::string & filename,
const std::string & extension,
const archive_options_isolate & options);
bool get_children_of(archive_listing_callback callback,
void *context,
const std::string & dir,
bool fetch_ea = false);
const std::vector<list_entry> get_children_in_table(const std::string & dir, bool fetch_ea = false) const;
bool has_subdirectory(const std::string & dir) const;
const entree_stats get_stats() const { if(cat == nullptr) throw SRC_BUG; return cat->get_stats(); };
const std::list<signator> & get_signatories() const { return gnupg_signed; };
void init_catalogue() const;
const catalogue & get_catalogue() const;
void drop_all_filedescriptors(bool repairing);
void set_to_unsaved_data_and_FSA() { if(cat == nullptr) throw SRC_BUG; cat->set_to_unsaved_data_and_FSA(); };
bool get_catalogue_slice_layout(slice_layout & slicing) const;
U_64 get_first_slice_header_size() const;
U_64 get_non_first_slice_header_size() const;
private:
enum operation { oper_create, oper_isolate, oper_merge, oper_repair };
pile stack;
header_version ver;
catalogue *cat;
infinint local_cat_size;
bool exploitable;
bool lax_read_mode;
bool sequential_read;
std::list<signator> gnupg_signed;
slice_layout slices;
void free_mem();
void check_gnupg_signed() const;
const catalogue & get_cat() const { if(cat == nullptr) throw SRC_BUG; else return *cat; };
const header_version & get_header() const { return ver; };
bool get_sar_param(infinint & sub_file_size,
infinint & first_file_size,
infinint & last_file_size,
infinint & total_file_number);
std::shared_ptr<entrepot> get_entrepot();
infinint get_level2_size();
infinint get_cat_size() const { return local_cat_size; };
statistics op_create_in(operation op,
const path & fs_root,
const std::shared_ptr<entrepot> & sauv_path_t,
archive *ref_arch,
const mask & selection,
const mask & subtree,
const std::string & filename,
const std::string & extension,
bool allow_over,
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,
U_I compression_block_size,
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,
const filesystem_ids & same_fs,
comparison_fields what_to_check,
bool snapshot,
bool cache_directory_tagging,
const infinint & fixed_date,
const std::string & slice_permission,
const infinint & repeat_count,
const infinint & repeat_byte,
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,
U_I multi_threaded_crypto,
U_I multi_threaded_compress,
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,
const delta_sig_block_size & sig_block_len,
bool never_resave_uncompressed,
statistics * progressive_report);
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,
U_I compression_block_size,
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,
const filesystem_ids & 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,
U_I multi_threaded_crypto,
U_I multi_threaded_compress,
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,
const delta_sig_block_size & sign_block_len,
bool never_resave_uncompressed,
statistics * st_ptr
);
void disable_natural_destruction();
void enable_natural_destruction();
const label & get_layer1_data_name() const;
const label & get_catalogue_data_name() const;
bool only_contains_an_isolated_catalogue() const;
void check_against_isolation(bool lax) const;
const cat_directory *get_dir_object(const std::string & dir) const;
void load_catalogue(bool repairing);
};
} // end of namespace
#endif
archive.hpp
the archive class is defined in this module
archive_listing_callback.hpp
definition of the user defined callback function used for archive listing
archive_options.hpp
this file contains a set of classes used to transmit options to archive operation
archive_summary.hpp
datastructure returned by archive::summary_data
catalogue.hpp
here is defined the classe used to manage catalogue of archives
libdar::archive::i_archive
the archive::i_archive class implements the most general operations on archives
Definition i_archive.hpp:59
libdar::archive_options_create
class holding optional parameters used to create an archive
Definition archive_options.hpp:305
libdar::archive_options_extract
class holding optional parameters used to extract files from an existing archive
Definition archive_options.hpp:1351
libdar::archive_options_isolate
class holding optional parameters used to isolate an existing archive
Definition archive_options.hpp:781
libdar::archive_options_listing
class holding optional parameters used to list the contents of an existing archive
Definition archive_options.hpp:1514
libdar::archive_options_merge
class holding optional parameters used to proceed to the merge operation
Definition archive_options.hpp:1024
libdar::archive_options_read
class holding optional parameters used to read an existing archive
Definition archive_options.hpp:70
libdar::archive_options_repair
class holding optional parameters used to create an archive
Definition archive_options.hpp:1821
libdar::archive_options_test
class holding optional parameters used to test the structure coherence of an existing archive
Definition archive_options.hpp:1738
libdar::archive_summary
the archive_summary class provides information about a given archive
Definition archive_summary.hpp:45
libdar::cat_directory
the cat_directory inode class
Definition cat_directory.hpp:52
libdar::catalogue
the catalogue class which gather all objects contained in a give archive
Definition catalogue.hpp:60
libdar::crit_action
the global action for overwriting
Definition crit_action.hpp:81
libdar::header_version
manages the archive header and trailer
Definition header_version.hpp:48
libdar::infinint
the arbitrary large positive integer class
Definition real_infinint.hpp:62
libdar::label
manage label data structure used in archive slice headers
Definition label.hpp:43
libdar::mask
the generic class, parent of all masks
Definition mask.hpp:62
libdar::mem_ui::mem_ui
mem_ui(const std::shared_ptr< user_interaction > &dialog)
constructor
libdar::path
the class path is here to manipulate paths in the Unix notation: using'/'
Definition path.hpp:51
libdar::pile
stores a stack of generic_files writing/reading on each others
Definition pile.hpp:44
libdar::secu_string
class secu_string
Definition secu_string.hpp:54
libdar::statistics
class used by libdar::archive class to give a summary of treated file during and after an operation
Definition statistics.hpp:70
crypto.hpp
the crypto algoritm definition
erreurs.hpp
contains all the excetion class thrown by libdar
libdar::modified_data_detection
modified_data_detection
how to detect data has changed when some fields
Definition archive_aux.hpp:44
libdar::comparison_fields
comparison_fields
how to consider file change during comparison and incremental backup
Definition archive_aux.hpp:53
libdar::archive::i_archive::get_catalogue
const catalogue & get_catalogue() const
gives access to internal catalogue (not to be used from the API)
libdar::archive::i_archive::cat
catalogue * cat
archive contents
Definition i_archive.hpp:212
libdar::archive::i_archive::i_archive
i_archive(const std::shared_ptr< user_interaction > &dialog, const path &sauv_path, std::shared_ptr< archive > ref_arch1, const std::string &filename, const std::string &extension, const archive_options_merge &options, statistics *progressive_report)
this constructor builds an archive from two given archive [this is the "merge" constructor]
libdar::archive::i_archive::only_contains_an_isolated_catalogue
bool only_contains_an_isolated_catalogue() const
true if the current archive only contains an isolated catalogue
libdar::archive::i_archive::ver
header_version ver
information for the archive header
Definition i_archive.hpp:211
libdar::archive::i_archive::stack
pile stack
the different layer through which the archive contents is read or wrote
Definition i_archive.hpp:210
libdar::archive::i_archive::i_archive
i_archive(const std::shared_ptr< user_interaction > &dialog, const path &fs_root, const path &sauv_path, const std::string &filename, const std::string &extension, const archive_options_create &options, statistics *progressive_report)
this constuctor create an archive (full or differential) [this is the "create" constructor]
libdar::archive::i_archive::exploitable
bool exploitable
is false if only the catalogue is available (for reference backup or isolation).
Definition i_archive.hpp:214
libdar::archive::i_archive::op_diff
statistics op_diff(const path &fs_root, const archive_options_diff &options, statistics *progressive_report)
archive comparison with filesystem
libdar::archive::i_archive::get_first_slice_header_size
U_64 get_first_slice_header_size() const
get the first slice header
libdar::archive::i_archive::i_archive
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]
libdar::archive::i_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 i_archive.hpp:192
libdar::archive::i_archive::sequential_read
bool sequential_read
whether the archive is read in sequential mode
Definition i_archive.hpp:216
libdar::archive::i_archive::drop_all_filedescriptors
void drop_all_filedescriptors(bool repairing)
closes all filedescriptors and associated even when in sequential read mode
libdar::archive::i_archive::op_isolate
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
libdar::archive::i_archive::get_signatories
const std::list< signator > & get_signatories() const
retrieving signature information about the archive
Definition i_archive.hpp:177
libdar::archive::i_archive::op_listing
void op_listing(archive_listing_callback callback, void *context, const archive_options_listing &options) const
listing of the archive contents
libdar::archive::i_archive::summary
void summary()
display a summary of the archive
libdar::hash_algo
hash_algo
hashing algorithm available
Definition archive_aux.hpp:63
libdar::archive::i_archive::get_catalogue_slice_layout
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
libdar::archive::i_archive::get_stats
const entree_stats get_stats() const
retrieving statistics about archive contents
Definition i_archive.hpp:174
libdar::archive::i_archive::lax_read_mode
bool lax_read_mode
whether the archive has been openned in lax mode (unused for creation/merging/isolation)
Definition i_archive.hpp:215
libdar::archive::i_archive::i_archive
i_archive(const i_archive &ref)=delete
copy constructor (not implemented, throw an exception if called explicitely or implicitely)
libdar::archive::i_archive::get_non_first_slice_header_size
U_64 get_non_first_slice_header_size() const
get the non first slice header
libdar::archive::i_archive::init_catalogue
void init_catalogue() const
libdar::archive::i_archive::check_against_isolation
void check_against_isolation(bool lax) const
throw Erange exception if the archive only contains an isolated catalogue
libdar::fsa_scope
std::set< fsa_family > fsa_scope
set of fsa families
Definition fsa_family.hpp:70
libdar::archive::i_archive::summary_data
archive_summary summary_data()
same information as summary() but as broken out data
libdar::compression
compression
the different compression algorithm available
Definition compression.hpp:46
libdar::archive::i_archive::get_children_in_table
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)
libdar::archive::i_archive::op_extract
statistics op_extract(const path &fs_root, const archive_options_extract &options, statistics *progressive_report)
extraction of data from an archive
libdar::archive::i_archive::~i_archive
~i_archive()
the destructor
Definition i_archive.hpp:113
libdar::archive::i_archive::i_archive
i_archive(const std::shared_ptr< user_interaction > &dialog, const path &chem_src, const std::string &basename_src, const std::string &extension_src, const archive_options_read &options_read, const path &chem_dst, const std::string &basename_dst, const std::string &extension_dst, const archive_options_repair &options_repair, statistics *progressive_report)
this constructor create a new archive from a damaged one [this is the "repair" constructor]
libdar::crypto_algo
crypto_algo
the different cypher available for encryption (strong or weak)
Definition crypto.hpp:50
libdar::archive::archive
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]
libdar::archive_listing_callback
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()
Definition archive_listing_callback.hpp:40
libdar::archive::i_archive::op_test
statistics op_test(const archive_options_test &options, bool reparing, statistics *progressive_report)
test the archive integrity
libdar::archive::i_archive::slices
slice_layout slices
slice layout, archive is not sliced <=> first_size or other_size fields are set to zero (in practice ...
Definition i_archive.hpp:218
libdar::archive::i_archive::gnupg_signed
std::list< signator > gnupg_signed
list of signature found in the archive (reading an existing archive)
Definition i_archive.hpp:217
libdar::archive::i_archive::local_cat_size
infinint local_cat_size
size of the catalogue on disk
Definition i_archive.hpp:213
libdar::archive::i_archive::get_entrepot
std::shared_ptr< entrepot > get_entrepot()
this method may return nullptr if no entrepot is used (pipes used for archive building,...
libdar::archive::i_archive::get_children_of
bool get_children_of(archive_listing_callback callback, void *context, const std::string &dir, bool fetch_ea=false)
getting information about a given directory
libdar::archive::i_archive::op_create_in_sub
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, U_I compression_block_size, 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, const filesystem_ids &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, U_I multi_threaded_crypto, U_I multi_threaded_compress, 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, const delta_sig_block_size &sign_block_len, bool never_resave_uncompressed, statistics *st_ptr)
libdar::archive::i_archive::has_subdirectory
bool has_subdirectory(const std::string &dir) const
returns true if the pointed directory has one or more subdirectories
header_version.hpp
archive global header/trailer structure is defined here
list_entry.hpp
class of objects describing an entry in the archive, used by archive::get_children_in_table
mem_ui.hpp
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47
path.hpp
here is the definition of the path class
pile.hpp
class pile definition. Used to manage a stack of generic_file objects
slice_layout.hpp
object describing the slicing of an archive
statistics.hpp
class handling access to the data summary of treated files after and during each operation
libdar::delta_sig_block_size
defines how to calculate delta signature block size based of file size to delta sign
Definition delta_sig_block_size.hpp:50
libdar::entree_stats
holds the statistics contents of a catalogue
Definition entree_stats.hpp:49