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

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

database.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 DATABASE_HPP
28 #define DATABASE_HPP
29
30 #include "../my_config.h"
31
32 #include <list>
33
34 #include "archive.hpp"
35 #include "generic_file.hpp"
36 #include "data_tree.hpp"
37 #include "storage.hpp"
38 #include "database_options.hpp"
39 #include "on_pool.hpp"
40
41 namespace libdar
42 {
44
49 class database : public on_pool
50 {
51 public:
53 database();
54
56
60 database(user_interaction & dialog, const std::string & base, const database_open_options & opt);
61
63 ~database();
64
66
71 void dump(user_interaction & dialog, const std::string & filename, const database_dump_options & opt) const;
72
73 // SETTINGS
74
76
82 void add_archive(const archive & arch, const std::string & chemin, const std::string & basename, const database_add_options & opt);
83
85
92 void remove_archive(archive_num min, archive_num max, const database_remove_options & opt);
93
95
99 void set_permutation(archive_num src, archive_num dst);
100
102
107 void change_name(archive_num num, const std::string & basename, const database_change_basename_options &opt);
108
110
115 void set_path(archive_num num, const std::string & chemin, const database_change_path_options & opt);
116
118
124 void set_options(const std::vector<std::string> &opt) { options_to_dar = opt; };
125
127
131 void set_dar_path(const std::string & chemin) { dar_path = chemin; };
132
133
134 // "GETTINGS"
135
137
139 void show_contents(user_interaction & dialog) const; // displays all archive information
140
142 std::vector<std::string> get_options() const { return options_to_dar; }; // show option passed to dar
143
145
148 std::string get_dar_path() const { return dar_path; }; // show path to dar command
149
151
157 void show_files(user_interaction & dialog, archive_num num, const database_used_options & opt) const;
158
160
164 void show_version(user_interaction & dialog, path chemin) const;
165
167
170 void show_most_recent_stats(user_interaction & dialog) const;
171
172 // "ACTIONS" (not available with partially extracted databases)
173
175
180 void restore(user_interaction & dialog,
181 const std::vector<std::string> & filename,
182 const database_restore_options & opt);
183
185
189 bool check_order(user_interaction & dialog) const
190 {
191 bool initial_warn = true;
192
193 if(files == nullptr)
194 throw SRC_BUG;
195 if(check_order_asked)
196 return files->check_order(dialog, ".", initial_warn) && initial_warn;
197 else
198 return true;
199 }
200
201
202 private:
203
205 struct archive_data
206 {
207 std::string chemin; //< path to the archive
208 std::string basename; //< basename of the archive
209 datetime root_last_mod; //< last modification date of the root directory
210 };
211
212 std::vector<struct archive_data> coordinate; //< list of archive used to build the database
213 std::vector<std::string> options_to_dar; //< options to use when calling dar for restoration
214 std::string dar_path; //< path to dar
215 data_dir *files; //< structure containing files and their status in the set of archive used for that database (is set to nullptr in partial mode)
216 storage *data_files; //< when reading archive in partial mode, this is where is located the "not readed" part of the archive (is set to nullptr in partial-read-only mode)
217 bool check_order_asked; //< whether order check has been asked
218 unsigned char cur_db_version; //< current db version (for informational purposes)
219
220 void build(user_interaction & dialog, generic_file & f, bool partial, bool read_only, unsigned char db_version); //< used by constructors
221 archive_num get_real_archive_num(archive_num num, bool revert) const;
222
223 const datetime & get_root_last_mod(const archive_num & num) const;
224 };
225
226 } // end of namespace
227
228 #endif
libdar::on_pool
Definition: on_pool.hpp:52
libdar::database::database
database()
this constructor build an empty database
libdar::database::check_order
bool check_order(user_interaction &dialog) const
check that all files's Data and EA are more recent when archive number grows within the database...
Definition: database.hpp:189
libdar::database_used_options
options for file "used" in archive
Definition: database_options.hpp:243
libdar::database_change_path_options
options for changing a given archive's path
Definition: database_options.hpp:159
libdar::database_add_options
options to add an archive to base
Definition: database_options.hpp:110
archive.hpp
the archive class is defined in this module
libdar::database::restore
void restore(user_interaction &dialog, const std::vector< std::string > &filename, const database_restore_options &opt)
restore files calling dar on the appropriated archive
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::remove_archive
void remove_archive(archive_num min, archive_num max, const database_remove_options &opt)
remove an archive from a database
generic_file.hpp
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
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::show_most_recent_stats
void show_most_recent_stats(user_interaction &dialog) const
compute some statistics about the location of most recent file versions
libdar::database::show_contents
void show_contents(user_interaction &dialog) const
show the list of archive used to build the database
libdar::database::dump
void dump(user_interaction &dialog, const std::string &filename, const database_dump_options &opt) const
write the database to a file (see database_header first)
data_tree.hpp
two classes used to store tree information in dar_manager databases
libdar::data_dir::check_order
bool check_order(user_interaction &dialog, const path &current_path, bool &initial_warn) const
check date order between archives withing the database ; throw Erange if problem found with date orde...
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
storage.hpp
contains a class that permits arbitrary large data storage
libdar::database_change_basename_options
options for changing a given archive's basename
Definition: database_options.hpp:139
libdar::database_remove_options
options to remove an archive from the base
Definition: database_options.hpp:120
libdar::database_open_options
options to open a database
Definition: database_options.hpp:43
libdar::database_dump_options
options to write a database to file
Definition: database_options.hpp:86
libdar::database::get_options
std::vector< std::string > get_options() const
return the options used with dar for restoration
Definition: database.hpp:142
libdar::archive
the archive class realizes the most general operations on archives
Definition: archive.hpp:56
libdar::database::get_dar_path
std::string get_dar_path() const
return the path for dar
Definition: database.hpp:148
libdar::database::~database
~database()
database destructor (no implicit file saving)
libdar::database::show_version
void show_version(user_interaction &dialog, path chemin) const
list the archive where a give file is present
libdar::database_restore_options
options for restoration from database
Definition: database_options.hpp:178
libdar::database::set_dar_path
void set_dar_path(const std::string &chemin)
change the path to dar command
Definition: database.hpp:131
libdar::database::set_permutation
void set_permutation(archive_num src, archive_num dst)
change order of archive within the database
on_pool.hpp
this is the base class of object that can be allocated on a memory pool
libdar::database::show_files
void show_files(user_interaction &dialog, archive_num num, const database_used_options &opt) const
list files which are present in a given archive
database_options.hpp
this file holds the options for database operations
libdar::database::set_options
void set_options(const std::vector< std::string > &opt)
change the default options given to dar when performing restoration
Definition: database.hpp:124
libdar::archive_num
U_16 archive_num
Definition: data_tree.hpp:51
libdar::database
the database class defines the dar_manager database
Definition: database.hpp:49
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
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
libdar::path
the class path is here to manipulate paths in the Unix notation: using'/'
Definition: path.hpp:50