|
Disk ARchive
2.4.12
|
00001 /*********************************************************************/ 00002 // dar - disk archive - a backup/restoration program 00003 // Copyright (C) 2002-2052 Denis Corbin 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 // 00019 // to contact the author : http://dar.linux.free.fr/email.html 00020 /*********************************************************************/ 00021 00025 00026 00027 #ifndef DATABASE_HPP 00028 #define DATABASE_HPP 00029 00030 #include "../my_config.h" 00031 00032 #include <list> 00033 00034 #include "archive.hpp" 00035 #include "generic_file.hpp" 00036 #include "data_tree.hpp" 00037 #include "storage.hpp" 00038 #include "database_options.hpp" 00039 00040 namespace libdar 00041 { 00043 00048 class database 00049 { 00050 public: 00052 database(); 00053 00055 00059 database(user_interaction & dialog, const std::string & base, const database_open_options & opt); 00060 00062 ~database(); 00063 00065 00069 void dump(user_interaction & dialog, const std::string & filename, const database_dump_options & opt) const; 00070 00071 // SETTINGS 00072 00074 00080 void add_archive(const archive & arch, const std::string & chemin, const std::string & basename, const database_add_options & opt); 00081 00083 00090 void remove_archive(archive_num min, archive_num max, const database_remove_options & opt); 00091 00093 00097 void set_permutation(archive_num src, archive_num dst); 00098 00100 00104 void change_name(archive_num num, const std::string & basename, const database_change_basename_options &opt); 00105 00107 00111 void set_path(archive_num num, const std::string & chemin, const database_change_path_options & opt); 00112 00114 00119 void set_options(const std::vector<std::string> &opt) { options_to_dar = opt; }; 00120 00122 00125 void set_dar_path(const std::string & chemin) { dar_path = chemin; }; 00126 00127 00128 // "GETTINGS" 00129 00131 00134 void show_contents(user_interaction & dialog) const; // displays all archive information 00135 00137 std::vector<std::string> get_options() const { return options_to_dar; }; // show option passed to dar 00138 00140 00143 std::string get_dar_path() const { return dar_path; }; // show path to dar command 00144 00146 00152 void show_files(user_interaction & dialog, archive_num num, const database_used_options & opt) const; 00153 00155 00159 void show_version(user_interaction & dialog, path chemin) const; 00160 00162 00165 void show_most_recent_stats(user_interaction & dialog) const; 00166 00167 // "ACTIONS" (not available with partially extracted databases) 00168 00170 00174 void restore(user_interaction & dialog, 00175 const std::vector<std::string> & filename, 00176 const database_restore_options & opt); 00177 00179 00182 00183 bool check_order(user_interaction & dialog) const 00184 { 00185 bool initial_warn = true; 00186 00187 if(files == NULL) 00188 throw SRC_BUG; 00189 if(check_order_asked) 00190 return files->check_order(dialog, ".", initial_warn) && initial_warn; 00191 else 00192 return true; 00193 } 00194 00195 00196 private: 00197 00199 struct archive_data 00200 { 00201 std::string chemin; //< path to the archive 00202 std::string basename; //< basename of the archive 00203 infinint root_last_mod; //< last modification date of the root directory 00204 }; 00205 00206 std::vector<struct archive_data> coordinate; //< list of archive used to build the database 00207 std::vector<std::string> options_to_dar; //< options to use when calling dar for restoration 00208 std::string dar_path; //< path to dar 00209 data_dir *files; //< structure containing files and their status in the set of archive used for that database (is set to NULL in partial mode) 00210 storage *data_files; //< when reading archive in partial mode, this is where is located the "not readed" part of the archive (is set to NULL in partial-read-only mode) 00211 bool check_order_asked; //< whether order check has been asked 00212 00213 void build(user_interaction & dialog, generic_file & f, bool partial, bool read_only, unsigned char db_version); //< used by constructors 00214 archive_num get_real_archive_num(archive_num num, bool revert) const; 00215 00216 const infinint & get_root_last_mod(const archive_num & num) const; 00217 }; 00218 00219 } // end of namespace 00220 00221 #endif
1.7.6.1