Disk ARchive  2.4.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
archive.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 // $Id$
00022 //
00023 /*********************************************************************/
00024 //
00025 
00029 
00030 
00031 #ifndef ARCHIVE_HPP
00032 #define ARCHIVE_HPP
00033 
00034 #include "../my_config.h"
00035 
00036 #include "path.hpp"
00037 #include "scrambler.hpp"
00038 #include "statistics.hpp"
00039 #include "archive_options.hpp"
00040 #include "escape.hpp"
00041 #include "escape_catalogue.hpp"
00042 #include "pile.hpp"
00043 
00044 namespace libdar
00045 {
00046 
00048 
00053     class archive
00054     {
00055     public:
00056 
00058 
00065         archive(user_interaction & dialog,
00066                 const path & chem,
00067                 const std::string & basename,
00068                 const std::string & extension,
00069                 const archive_options_read & options);
00070 
00071 
00073 
00092         archive(user_interaction & dialog,
00093                 const path & fs_root,
00094                 const path & sauv_path,
00095                 const std::string & filename,
00096                 const std::string & extension,
00097                 const archive_options_create & options,
00098                 statistics * progressive_report);
00099 
00100 
00102 
00109         archive(user_interaction & dialog,
00110                 const path &sauv_path,
00111                 archive *ref_arch,
00112                 const std::string & filename,
00113                 const std::string & extension,
00114                 const archive_options_isolate & options);
00115 
00116 
00118 
00133 
00134         archive(user_interaction & dialog,
00135                 const path & sauv_path,
00136                 archive *ref_arch1,
00137                 const std::string & filename,
00138                 const std::string & extension,
00139                 const archive_options_merge & options,
00140                 statistics * progressive_report);
00141 
00143 
00148 
00149         archive(const archive & ref) : stack(ref.stack) { throw Efeature(gettext("Archive copy constructor is not implemented")); };
00150         archive & operator = (const archive & ref) { throw Efeature(gettext("Archive assignment operator is not implemented")); };
00151 
00153         ~archive() { free(); };
00154 
00155 
00157 
00176         statistics op_extract(user_interaction & dialog,
00177                               const path &fs_root,
00178                               const archive_options_extract & options,
00179                               statistics *progressive_report);
00180 
00182 
00183         void summary(user_interaction & dialog);
00184 
00185 
00187 
00190         void op_listing(user_interaction & dialog,
00191                         const archive_options_listing & options);
00192 
00194 
00208         statistics op_diff(user_interaction & dialog,
00209                            const path & fs_root,
00210                            const archive_options_diff & options,
00211                            statistics * progressive_report);
00212 
00213 
00215 
00235         statistics op_test(user_interaction & dialog,
00236                            const archive_options_test & options,
00237                            statistics * progressive_report);
00238 
00239 
00241 
00249         bool get_children_of(user_interaction & dialog,
00250                              const std::string & dir);
00251 
00253         const entree_stats get_stats() const { if(cat == NULL) throw SRC_BUG; return cat->get_stats(); };
00254 
00256 
00263         const catalogue & get_catalogue() const;
00264 
00266         const catalogue & get_catalogue(user_interaction & dialog) const;
00267 
00269 
00275         void drop_all_filedescriptors();
00276 
00278 
00279         void drop_all_filedescriptors(user_interaction & dialog);
00280 
00281     private:
00282         enum operation { oper_create, oper_isolate, oper_merge };
00283 
00284         pile stack;
00285         header_version ver;
00286         catalogue *cat;
00287         infinint local_cat_size;
00288         path *local_path;
00289         bool exploitable; //< is false if only the catalogue is available (for reference backup or isolation).
00290         bool lax_read_mode; //< whether the archive has been openned in lax mode (unused for creation/merging/isolation)
00291         bool sequential_read; //< whether the archive is read in sequential mode
00292 
00293         void free();
00294         catalogue & get_cat() { if(cat == NULL) throw SRC_BUG; else return *cat; };
00295         const header_version & get_header() const { return ver; };
00296         const path & get_path() { if(local_path == NULL) throw SRC_BUG; else return *local_path; };
00297 
00298         bool get_sar_param(infinint & sub_file_size, infinint & first_file_size, infinint & last_file_size,
00299                            infinint & total_file_number);
00300         infinint get_level2_size();
00301         infinint get_cat_size() const { return local_cat_size; };
00302 
00303         statistics op_create_in(user_interaction & dialog,
00304                                 operation op,
00305                                 const path & fs_root,
00306                                 const path & sauv_path,
00307                                 archive *ref_arch,
00308                                 const mask & selection,
00309                                 const mask & subtree,
00310                                 const std::string & filename,
00311                                 const std::string & extension,
00312                                 bool allow_over,
00313                                 bool warn_over,
00314                                 bool info_details,
00315                                 const infinint & pause,
00316                                 bool empty_dir,
00317                                 compression algo,
00318                                 U_I compression_level,
00319                                 const infinint & file_size,
00320                                 const infinint & first_file_size,
00321                                 const mask & ea_mask,
00322                                 const std::string & execute,
00323                                 crypto_algo crypto,
00324                                 const secu_string & pass,
00325                                 U_32 crypto_size,
00326                                 const mask & compr_mask,
00327                                 const infinint & min_compr_size,
00328                                 bool nodump,
00329                                 const infinint & hourshift,
00330                                 bool empty,
00331                                 bool alter_atime,
00332                                 bool furtive_read_mode,
00333                                 bool same_fs,
00334                                 inode::comparison_fields what_to_check,
00335                                 bool snapshot,
00336                                 bool cache_directory_tagging,
00337                                 bool display_skipped,
00338                                 const infinint & fixed_date,
00339                                 const std::string & slice_permission,
00340                                 const std::string & slice_user_ownership,
00341                                 const std::string & slice_group_ownership,
00342                                 const infinint & repeat_count,
00343                                 const infinint & repeat_byte,
00344                                 bool add_marks_for_sequential_reading,
00345                                 bool security_check,
00346                                 const infinint & sparse_file_min_size,
00347                                 const std::string & user_comment,
00348                                 hash_algo hash,
00349                                 const infinint & slice_min_digits,
00350                                 const std::string & backup_hook_file_execute,
00351                                 const mask & backup_hook_file_mask,
00352                                 bool ignore_unknown,
00353                                 statistics * progressive_report);
00354 
00355         void op_create_in_sub(user_interaction & dialog,        //< interaction with user
00356                               operation op,                     //< the filter operation to bind to
00357                               const path & fs_root,             //< root of the filesystem to act on
00358                               const path & sauv_path_t,         //< where to create the archive
00359                               catalogue  * ref_arch1,           //< catalogue of the archive of reference (a catalogue must be provided in any case, a empty one shall fit for no reference)
00360                               catalogue  * ref_arch2,           //< secondary catalogue used for merging, can be NULL if not used
00361                               const path * ref_path,            //< path of the archive of archive of reference (NULL if there is no archive of reference used, thus ref_arch (previous arg) is probably an empty archive)
00362                               const mask & selection,           //< filter on filenames
00363                               const mask & subtree,             //< filter on directory tree and filenames
00364                               const std::string & filename,     //< basename of the archive to create
00365                               const std::string & extension,    //< extension of the archives
00366                               bool allow_over,                  //< whether to allow overwriting (of slices)
00367                               const crit_action & overwrite,    //< whether and how to allow overwriting (for files inside the archive)
00368                               bool warn_over,                   //< whether to warn before overwriting
00369                               bool info_details,                //< whether to display detailed informations
00370                               const infinint & pause,           //< whether to pause between slices
00371                               bool empty_dir,                   //< whether to store excluded dir as empty directories
00372                               compression algo,                 //< compression algorithm
00373                               U_I compression_level,            //< compression level (range 1 to 9)
00374                               const infinint & file_size,       //< slice size
00375                               const infinint & first_file_size, //< first slice size
00376                               const mask & ea_mask,             //< Extended Attribute to consider
00377                               const std::string & execute,      //< Command line to execute between slices
00378                               crypto_algo crypto,               //< crypt algorithm
00379                               const secu_string & pass,         //< password ("" for onfly request of password)
00380                               U_32 crypto_size,                 //< size of crypto blocks
00381                               const mask & compr_mask,          //< files to compress
00382                               const infinint & min_compr_size,  //< file size under which to not compress files
00383                               bool nodump,                      //< whether to consider the "nodump" filesystem flag
00384                               const infinint & hourshift,       //< hourshift (see man page -H option)
00385                               bool empty,                       //< whether to make an "dry-run" execution
00386                               bool alter_atime,                 //< whether to alter atime date (by opposition to ctime) when reading files
00387                               bool furtive_read_mode,           //< whether to neither alter atime nor ctome (if true alter_atime is ignored)
00388                               bool same_fs,                     //< confin the files consideration to a single filesystem
00389                               inode::comparison_fields what_to_check,  //< fields to consider wien comparing inodes (see inode::comparison_fields enumeration)
00390                               bool snapshot,                    //< make as if all file had not changed
00391                               bool cache_directory_tagging,     //< avoid saving directory which follow the cache directory tagging
00392                               bool display_skipped,             //< display skipped files for the operation
00393                               bool keep_compressed,             //< keep file compressed when merging
00394                               const infinint & fixed_date,      //< whether to ignore any archive of reference and only save file which modification is more recent that the given "fixed_date" date
00395                               const std::string & slice_permission,      //< permissions of slices that will be created
00396                               const std::string & slice_user_ownership,  //< user ownership of slices that will be created
00397                               const std::string & slice_group_ownership, //< group ownership of slices that will be created
00398                               const infinint & repeat_count,             //< max number of retry to save a file that have changed while it was read for backup
00399                               const infinint & repeat_byte,              //< max amount of wasted data used to save a file that have changed while it was read for backup
00400                               bool decremental,                          //< in the merging context only, whether to build a decremental backup from the two archives of reference
00401                               bool add_marks_for_sequential_reading,     //< whether to add marks for sequential reading
00402                               bool security_check,                       //< whether to check for ctime change with no reason (rootkit ?)
00403                               const infinint & sparse_file_min_size,     //< starting which size to consider looking for holes in sparse files (0 for no detection)
00404                               const std::string & user_comment,          //< user comment to put in the archive
00405                               hash_algo hash,                            //< whether to produce hash file, and which algo to use
00406                               const infinint & slice_min_digits,         //< minimum digit for slice number
00407                               const std::string & backup_hook_file_execute, //< command to execute before and after files to backup
00408                               const mask & backup_hook_file_mask,         //< files elected to have a command executed before and after their backup
00409                               bool ignore_unknown,                        //< whether to warn when an unknown inode type is met
00410                               statistics * st_ptr);             //< statistics must not be NULL !
00411 
00412         void disable_natural_destruction();
00413         void enable_natural_destruction();
00414         const label & get_layer1_data_name() const;
00415         const label & get_catalogue_data_name() const;
00416         bool only_contains_an_isolated_catalogue() const; //< true if the current archive only contains an isolated catalogue
00417         void check_against_isolation(user_interaction & dialog, bool lax) const; //< throw Erange exception if the archive only contains an isolated catalogue
00418         void check_header_version() const;
00419     };
00420 
00421 } // end of namespace
00422 
00423 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines