Disk ARchive 2.8.0
Full featured and portable backup and archiving tool
archive.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2025 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18//
19// to contact the author, see the AUTHOR file
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#include <memory>
34
35#include "erreurs.hpp"
36#include "path.hpp"
37#include "statistics.hpp"
38#include "archive_options.hpp"
39#include "list_entry.hpp"
40#include "crypto.hpp"
41#include "archive_summary.hpp"
43#include "user_interaction.hpp"
44
45
46namespace libdar
47{
48 // need to declare class database friend of class archive.
49 // class database need to access the archive table of content
50 // though exposing it by mean of a public method of class
51 // archive would let it visibile to the API, thing we do not
52 // want
53 class database;
54
57
59 constexpr const char* dar_extension = "dar";
60
62
66
67 class archive
68 {
69 public:
70
72
79 archive(const std::shared_ptr<user_interaction> & dialog,
80 const path & chem,
81 const std::string & basename,
82 const std::string & extension,
83 const archive_options_read & options);
84
85
87
105
106 archive(const std::shared_ptr<user_interaction> & dialog,
107 const path & fs_root,
108 const path & sauv_path,
109 const std::string & filename,
110 const std::string & extension,
111 const archive_options_create & options,
112 statistics * progressive_report);
113
115
129
130 archive(const std::shared_ptr<user_interaction> & dialog,
131 const path & sauv_path,
132 std::shared_ptr<archive> ref_arch1,
133 const std::string & filename,
134 const std::string & extension,
135 const archive_options_merge & options,
136 statistics* progressive_report);
137
139
160
161 archive(const std::shared_ptr<user_interaction> & dialog,
162 const path & chem_src,
163 const std::string & basename_src,
164 const std::string & extension_src,
165 const archive_options_read & options_read,
166 const path & chem_dst,
167 const std::string & basename_dst,
168 const std::string & extension_dst,
169 const archive_options_repair & options_repair,
170 statistics* progressive_report = nullptr);
171
172
174
179
180 archive(const archive & ref) = delete;
181 archive(archive && ref) = delete;
182 archive & operator = (const archive & ref) = delete;
183 archive & operator = (archive && ref) = delete;
184
187
188
190
207
208 statistics op_extract(const path &fs_root,
209 const archive_options_extract & options,
210 statistics *progressive_report);
211
213
215 void summary();
216
219
220
222
231 void *context,
232 const archive_options_listing & options) const;
233
235
247 statistics op_diff(const path & fs_root,
248 const archive_options_diff & options,
249 statistics * progressive_report);
250
251
253
272 statistics * progressive_report);
273
274
276
285 void op_isolate(const path &sauv_path,
286 const std::string & filename,
287 const std::string & extension,
288 const archive_options_isolate & options);
289
290
292
299 void *context,
300 const std::string & dir,
301 bool fetch_ea = false);
302
304
313 const std::vector<list_entry> get_children_in_table(const std::string & dir, bool fetch_ea = false) const;
314
316 bool has_subdirectory(const std::string & dir) const;
317
319 const entree_stats get_stats() const;
320
322 const std::list<signator> & get_signatories() const;
323
326 void init_catalogue() const;
327
329
332 void drop_all_filedescriptors(bool repairing = false);
333
336
338
347
349
352
353
354 private:
355 class i_archive;
356 std::shared_ptr<i_archive> pimpl;
357
358 // see the comment near the forward declaration
359 // of class database above for explanations
360 friend class database;
361 };
362
363} // end of namespace
364
365#endif
definition of the user defined callback function used for archive listing
this file contains a set of classes used to transmit options to archive operation
datastructure returned by archive::summary_data
the archive::i_archive class implements the most general operations on archives
Definition: i_archive.hpp:59
class holding optional parameters used to create an archive
class holding optional parameters used to extract files from an existing archive
class holding optional parameters used to isolate an existing archive
class holding optional parameters used to list the contents of an existing archive
class holding optional parameters used to proceed to the merge operation
class holding optional parameters used to read an existing archive
class holding optional parameters used to create an archive
class holding optional parameters used to test the structure coherence of an existing archive
the archive_summary class provides information about a given archive
the archive class realizes the most general operations on archives
Definition: archive.hpp:68
the database class defines the dar_manager database
Definition: database.hpp:52
the class path is here to manipulate paths in the Unix notation: using'/'
Definition: path.hpp:51
class used by libdar::archive class to give a summary of treated file during and after an operation
Definition: statistics.hpp:70
the crypto algoritm definition
contains all the excetion class thrown by libdar
archive(const archive &ref)=delete
copy constructor (not implemented, throw an exception if called explicitely or implicitely)
void drop_all_filedescriptors(bool repairing=false)
closes all filedescriptors and associated even when in sequential read mode
statistics op_test(const archive_options_test &options, statistics *progressive_report)
test the archive integrity
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()
statistics op_diff(const path &fs_root, const archive_options_diff &options, statistics *progressive_report)
archive comparison with filesystem
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=nullptr)
this constructor create a new archive from a damaged one [this is the "repair" constructor]
const std::list< signator > & get_signatories() const
retrieving signature information about the archive
archive_summary summary_data()
same information as summary() but as broken out data
const entree_stats get_stats() const
retrieving statistics about archive contents
void init_catalogue() const
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)
void summary()
display a summary of the archive
bool get_children_of(archive_listing_callback callback, void *context, const std::string &dir, bool fetch_ea=false)
getting information about a given directory
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]
bool has_subdirectory(const std::string &dir) const
returns true if the pointed directory has one or more subdirectories
constexpr const char * dar_extension
the default extension for dar archive
Definition: archive.hpp:59
U_64 get_non_first_slice_header_size() const
get the non first slice header
U_64 get_first_slice_header_size() const
get the first slice header
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
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]
void op_listing(archive_listing_callback callback, void *context, const archive_options_listing &options) const
listing of the archive contents
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]
statistics op_extract(const path &fs_root, const archive_options_extract &options, statistics *progressive_report)
extraction of data from an archive
void set_to_unsaved_data_and_FSA()
change all inode as unsaved (equal to differential backup with no change met)
~archive()
the destructor
class of objects describing an entry in the archive, used by archive::get_children_in_table
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
here is the definition of the path class
class handling access to the data summary of treated files after and during each operation
holds the statistics contents of a catalogue
defines the interaction interface between libdar and users.