Disk ARchive  2.5.2
Full featured and portable backup and archiving tool
database.hpp
Go to the documentation of this file.
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 #include "on_pool.hpp"
00040 
00041 namespace libdar
00042 {
00044 
00049     class database : public on_pool
00050     {
00051     public:
00053     database();
00054 
00056 
00060     database(user_interaction & dialog, const std::string & base, const database_open_options & opt);
00061 
00063     ~database();
00064 
00066 
00071     void dump(user_interaction & dialog, const std::string & filename, const database_dump_options & opt) const;
00072 
00073         // SETTINGS
00074 
00076 
00082     void add_archive(const archive & arch, const std::string & chemin, const std::string & basename, const database_add_options & opt);
00083 
00085 
00092     void remove_archive(archive_num min, archive_num max, const database_remove_options & opt);
00093 
00095 
00099     void set_permutation(archive_num src, archive_num dst);
00100 
00102 
00107     void change_name(archive_num num, const std::string & basename, const database_change_basename_options &opt);
00108 
00110 
00115     void set_path(archive_num num, const std::string & chemin, const database_change_path_options & opt);
00116 
00118 
00124         void set_options(const std::vector<std::string> &opt) { options_to_dar = opt; };
00125 
00127 
00131     void set_dar_path(const std::string & chemin) { dar_path = chemin; };
00132 
00133 
00134         // "GETTINGS"
00135 
00137 
00139     void show_contents(user_interaction & dialog) const; // displays all archive information
00140 
00142     std::vector<std::string> get_options() const { return options_to_dar; }; // show option passed to dar
00143 
00145 
00148     std::string get_dar_path() const { return dar_path; }; // show path to dar command
00149 
00151 
00157     void show_files(user_interaction & dialog, archive_num num, const database_used_options & opt) const;
00158 
00160 
00164     void show_version(user_interaction & dialog, path chemin) const;
00165 
00167 
00170     void show_most_recent_stats(user_interaction & dialog) const;
00171 
00172         // "ACTIONS" (not available with partially extracted databases)
00173 
00175 
00180     void restore(user_interaction & dialog,
00181              const std::vector<std::string> & filename,
00182              const database_restore_options & opt);
00183 
00185 
00189     bool check_order(user_interaction & dialog) const
00190     {
00191         bool initial_warn = true;
00192 
00193         if(files == nullptr)
00194         throw SRC_BUG;
00195         if(check_order_asked)
00196         return files->check_order(dialog, ".", initial_warn) && initial_warn;
00197         else
00198         return true;
00199     }
00200 
00201 
00202     private:
00203 
00205     struct archive_data
00206     {
00207         std::string chemin;      //< path to the archive
00208         std::string basename;    //< basename of the archive
00209         datetime root_last_mod;  //< last modification date of the root directory
00210     };
00211 
00212     std::vector<struct archive_data> coordinate; //< list of archive used to build the database
00213     std::vector<std::string> options_to_dar;     //< options to use when calling dar for restoration
00214     std::string dar_path;                        //< path to dar
00215     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)
00216     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)
00217     bool check_order_asked;                      //< whether order check has been asked
00218     unsigned char cur_db_version;                //< current db version (for informational purposes)
00219 
00220     void build(user_interaction & dialog, generic_file & f, bool partial, bool read_only, unsigned char db_version);  //< used by constructors
00221     archive_num get_real_archive_num(archive_num num, bool revert) const;
00222 
00223     const datetime & get_root_last_mod(const archive_num & num) const;
00224     };
00225 
00226 } // end of namespace
00227 
00228 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines