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

database.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2020 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 : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
25
26
27 #ifndef DATABASE_HPP
28 #define DATABASE_HPP
29
30 #include "../my_config.h"
31
32 #include <list>
33
34 #include "archive.hpp"
35 #include "database_options.hpp"
36 #include "database_archives.hpp"
37 #include "archive_num.hpp"
38 #include "database_listing_callback.hpp"
39
40 namespace libdar
41 {
42
45
47
51 class database
52 {
53 public:
55 database(const std::shared_ptr<user_interaction> & dialog);
56
58
62 database(const std::shared_ptr<user_interaction> & dialog,
63 const std::string & base,
64 const database_open_options & opt);
65
67 database(const database & ref) = delete;
68
70 database(database && ref) noexcept = delete;
71
73 database & operator = (const database & ref) = delete;
74
76 database & operator = (database && ref) noexcept = delete;
77
79 ~database();
80
82
86 void dump(const std::string & filename,
87 const database_dump_options & opt) const;
88
89 // SETTINGS
90
92
98 void add_archive(const archive & arch,
99 const std::string & chemin,
100 const std::string & basename,
101 const database_add_options & opt);
102
104
111 void remove_archive(archive_num min,
112 archive_num max,
113 const database_remove_options & opt);
114
116
120 void set_permutation(archive_num src, archive_num dst);
121
123
128 void change_name(archive_num num,
129 const std::string & basename,
130 const database_change_basename_options &opt);
131
133
138 void set_path(archive_num num,
139 const std::string & chemin,
140 const database_change_path_options & opt);
141
143
149 void set_options(const std::vector<std::string> &opt);
150
152
156 void set_dar_path(const std::string & chemin);
157
159 void set_compression(compression algozip);
160
161
162 // "GETTINGS"
163
165 database_archives_list get_contents() const;
166
168 std::vector<std::string> get_options() const;
169
171
174 std::string get_dar_path() const;
175
177 compression get_compression() const;
178
180 std::string get_database_version() const;
181
183
190 void get_files(database_listing_show_files_callback callback,
191 void *context,
192 archive_num num,
193 const database_used_options & opt) const;
194
196
201 void get_version(database_listing_get_version_callback callback,
202 void *context,
203 path chemin) const;
204
206
210 void show_most_recent_stats(database_listing_statistics_callback callback,
211 void *context) const;
212
213 // "ACTIONS" (not available with partially extracted databases)
214
216
220 void restore(const std::vector<std::string> & filename,
221 const database_restore_options & opt);
222
224
227 bool check_order() const;
228
229 private:
230 class i_database;
231 std::unique_ptr<i_database> pimpl;
232
233 };
234
236
237 } // end of namespace
238
239 #endif
archive.hpp
the archive class is defined in this module
libdar::database::change_name
void change_name(archive_num num, const std::string &basename, const database_change_basename_options &opt)
change one's archive basename recorded in the database
libdar::database::get_files
void get_files(database_listing_show_files_callback callback, void *context, archive_num num, const database_used_options &opt) const
list files which are present in a given archive
libdar::database_listing_statistics_callback
void(*)(void *context, U_I number, const infinint &data_count, const infinint &total_data, const infinint &ea_count, const infinint &total_ea) database_listing_statistics_callback
called with teh information of statistics for each archive in turn
Definition: database_listing_callback.hpp:86
libdar::database::get_options
std::vector< std::string > get_options() const
return the options used with dar for restoration
libdar::database::i_database
the class i_database is the implementation of class database
Definition: i_database.hpp:53
libdar::compression
compression
the different compression algorithm available
Definition: compression.hpp:46
libdar::database_restore_options
options for restoration from database
Definition: database_options.hpp:211
libdar::database::get_database_version
std::string get_database_version() const
return the database format version
libdar::database_change_path_options
options for changing a given archive's path
Definition: database_options.hpp:187
libdar::database::set_dar_path
void set_dar_path(const std::string &chemin)
change the path to dar command
libdar::database::restore
void restore(const std::vector< std::string > &filename, const database_restore_options &opt)
restore files calling dar on the appropriated archive
libdar::database
the database class defines the dar_manager database
Definition: database.hpp:52
libdar::database::remove_archive
void remove_archive(archive_num min, archive_num max, const database_remove_options &opt)
remove an archive from a database
libdar::database::add_archive
void add_archive(const archive &arch, const std::string &chemin, const std::string &basename, const database_add_options &opt)
add an archive to the database
libdar::database::operator=
database & operator=(const database &ref)=delete
disabling assignement operator
libdar::database::set_compression
void set_compression(compression algozip)
change compression to use when storing base on file
database_options.hpp
this file holds the options for database operations
libdar::database_open_options
options to open a database
Definition: database_options.hpp:44
libdar::database::database
database(const database &ref)=delete
disabling copy constructor
libdar::database_archives_list
std::deque< database_archives > database_archives_list
list of archives found in a database
Definition: database_archives.hpp:75
libdar::database::set_options
void set_options(const std::vector< std::string > &opt)
change the default options given to dar when performing restoration
libdar::database::set_path
void set_path(archive_num num, const std::string &chemin, const database_change_path_options &opt)
change one's archive path recorded in the database
libdar::database::get_version
void get_version(database_listing_get_version_callback callback, void *context, path chemin) const
list the archive where a give file is present
libdar::database::show_most_recent_stats
void show_most_recent_stats(database_listing_statistics_callback callback, void *context) const
compute some statistics about the location of most recent file versions
libdar::path
the class path is here to manipulate paths in the Unix notation: using'/'
Definition: path.hpp:51
libdar::database_listing_get_version_callback
void(*)(void *context, archive_num num, db_etat data_presence, bool has_data_date, datetime data, db_etat ea_presence, bool has_ea_date, datetime ea) database_listing_get_version_callback
called with the information of presence for an entry in archive number num
Definition: database_listing_callback.hpp:70
database_archives.hpp
this file stores the list of archives a database has been built from. it is part of the database head...
libdar::database::check_order
bool check_order() const
check that all files's Data and EA are more recent when archive number grows within the database,...
libdar::archive
the archive class realizes the most general operations on archives
Definition: archive.hpp:65
libdar::database_dump_options
options to write a database to file
Definition: database_options.hpp:93
libdar::archive_num
class archive_num stores the position of an archive inside a dar_manager database
Definition: archive_num.hpp:47
libdar::database::set_permutation
void set_permutation(archive_num src, archive_num dst)
change order of archive within the database
archive_num.hpp
class storing the position of an archive inside a database
libdar::database::get_dar_path
std::string get_dar_path() const
returns the path for dar
libdar::database_add_options
options to add an archive to base
Definition: database_options.hpp:123
libdar::database_used_options
options for file "used" in archive
Definition: database_options.hpp:281
libdar::database::dump
void dump(const std::string &filename, const database_dump_options &opt) const
write the database to a file (see database_header first)
libdar::database::database
database(const std::shared_ptr< user_interaction > &dialog)
this constructor build an empty database
libdar::database_remove_options
options to remove an archive from the base
Definition: database_options.hpp:138
libdar::database::database
database(database &&ref) noexcept=delete
disabling move constructor
database_listing_callback.hpp
definition of the user defined callback function used for database listing
libdar::database::~database
~database()
database destructor (no implicit file saving)
libdar::database_change_basename_options
options for changing a given archive's basename
Definition: database_options.hpp:162
libdar::database::database
database(const std::shared_ptr< user_interaction > &dialog, const std::string &base, const database_open_options &opt)
this constructor reads database from a file
libdar::database_listing_show_files_callback
void(*)(void *context, const std::string &filename, bool available_data, bool available_ea) database_listing_show_files_callback
called by the database::get_files() routine
Definition: database_listing_callback.hpp:51
libdar::database::get_compression
compression get_compression() const
returns the compression algorithm used on filesystem
libdar::database::get_contents
database_archives_list get_contents() const
provides the list of archive used to build the database
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47