Disk ARchive  2.4.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/libdar/database.hpp
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 // $Id$
00022 //
00023 /*********************************************************************/
00024 
00028 
00029 
00030 #ifndef DATABASE_HPP
00031 #define DATABASE_HPP
00032 
00033 #include "../my_config.h"
00034 
00035 #include <list>
00036 
00037 #include "archive.hpp"
00038 #include "generic_file.hpp"
00039 #include "data_tree.hpp"
00040 #include "storage.hpp"
00041 #include "database_options.hpp"
00042 
00043 namespace libdar
00044 {
00046 
00051     class database
00052     {
00053     public:
00055         database();
00056 
00058 
00062         database(user_interaction & dialog, const std::string & base, const database_open_options & opt);
00063 
00065         ~database();
00066 
00068 
00072         void dump(user_interaction & dialog, const std::string & filename, const database_dump_options & opt) const;
00073 
00074             // SETTINGS
00075 
00077 
00083         void add_archive(const archive & arch, const std::string & chemin, const std::string & basename, const database_add_options & opt);
00084 
00086 
00093         void remove_archive(archive_num min, archive_num max, const database_remove_options & opt);
00094 
00096 
00100         void set_permutation(archive_num src, archive_num dst);
00101 
00103 
00107         void change_name(archive_num num, const std::string & basename, const database_change_basename_options &opt);
00108 
00110 
00114         void set_path(archive_num num, const std::string & chemin, const database_change_path_options & opt);
00115 
00117 
00122         void set_options(const std::vector<std::string> &opt) { options_to_dar = opt; };
00123 
00125 
00128         void set_dar_path(const std::string & chemin) { dar_path = chemin; };
00129 
00130 
00131             // "GETTINGS"
00132 
00134 
00137         void show_contents(user_interaction & dialog) const; // displays all archive information
00138 
00140         std::vector<std::string> get_options() const { return options_to_dar; }; // show option passed to dar
00141 
00143 
00146         std::string get_dar_path() const { return dar_path; }; // show path to dar command
00147 
00149 
00155         void show_files(user_interaction & dialog, archive_num num, const database_used_options & opt) const;
00156 
00158 
00162         void show_version(user_interaction & dialog, path chemin) const;
00163 
00165 
00168         void show_most_recent_stats(user_interaction & dialog) const;
00169 
00170             // "ACTIONS" (not available with partially extracted databases)
00171 
00173 
00177         void restore(user_interaction & dialog,
00178                      const std::vector<std::string> & filename,
00179                      const database_restore_options & opt);
00180 
00182 
00185 
00186         bool check_order(user_interaction & dialog) const
00187         {
00188             bool initial_warn = true;
00189 
00190             if(files == NULL)
00191                 throw SRC_BUG;
00192             if(check_order_asked)
00193                 return files->check_order(dialog, ".", initial_warn) && initial_warn;
00194             else
00195                 return true;
00196         }
00197 
00198 
00199     private:
00200 
00202         struct archive_data
00203         {
00204             std::string chemin;      //< path to the archive
00205             std::string basename;    //< basename of the archive
00206             infinint root_last_mod;  //< last modification date of the root directory
00207         };
00208 
00209         std::vector<struct archive_data> coordinate; //< list of archive used to build the database
00210         std::vector<std::string> options_to_dar;     //< options to use when calling dar for restoration
00211         std::string dar_path;                        //< path to dar
00212         data_dir *files;                             //< structure containing files and they status in the set of archive used for that database
00213         storage *data_files;                         //< when reading archive in partial mode, this is where is located the "not readed" part of the archive
00214         bool check_order_asked;                      //< whether order check has been asked
00215 
00216         void build(user_interaction & dialog, generic_file & f, bool partial, unsigned char db_version);  //< used by constructors
00217         archive_num get_real_archive_num(archive_num num, bool revert) const;
00218 
00219         const infinint & get_root_last_mod(const archive_num & num) const;
00220     };
00221 
00222 } // end of namespace
00223 
00224 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines