|
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 ARCHIVE_HPP 00028 #define ARCHIVE_HPP 00029 00030 #include "../my_config.h" 00031 #include <vector> 00032 00033 #include "erreurs.hpp" 00034 #include "path.hpp" 00035 #include "scrambler.hpp" 00036 #include "statistics.hpp" 00037 #include "archive_options.hpp" 00038 #include "escape.hpp" 00039 #include "escape_catalogue.hpp" 00040 #include "pile.hpp" 00041 #include "list_entry.hpp" 00042 00043 namespace libdar 00044 { 00045 00047 00052 class archive 00053 { 00054 public: 00055 00057 00064 archive(user_interaction & dialog, 00065 const path & chem, 00066 const std::string & basename, 00067 const std::string & extension, 00068 const archive_options_read & options); 00069 00070 00072 00091 archive(user_interaction & dialog, 00092 const path & fs_root, 00093 const path & sauv_path, 00094 const std::string & filename, 00095 const std::string & extension, 00096 const archive_options_create & options, 00097 statistics * progressive_report); 00098 00099 00101 00108 archive(user_interaction & dialog, 00109 const path &sauv_path, 00110 archive *ref_arch, 00111 const std::string & filename, 00112 const std::string & extension, 00113 const archive_options_isolate & options); 00114 00115 00117 00132 00133 archive(user_interaction & dialog, 00134 const path & sauv_path, 00135 archive *ref_arch1, 00136 const std::string & filename, 00137 const std::string & extension, 00138 const archive_options_merge & options, 00139 statistics * progressive_report); 00140 00142 00147 00148 archive(const archive & ref) : stack(ref.stack) { throw Efeature(dar_gettext("Archive copy constructor is not implemented")); }; 00149 archive & operator = (const archive & ref) { throw Efeature(dar_gettext("Archive assignment operator is not implemented")); }; 00150 00152 ~archive() { free(); }; 00153 00154 00156 00175 statistics op_extract(user_interaction & dialog, 00176 const path &fs_root, 00177 const archive_options_extract & options, 00178 statistics *progressive_report); 00179 00183 void summary(user_interaction & dialog); 00184 00185 00187 00196 void op_listing(user_interaction & dialog, 00197 const archive_options_listing & options); 00198 00200 00214 statistics op_diff(user_interaction & dialog, 00215 const path & fs_root, 00216 const archive_options_diff & options, 00217 statistics * progressive_report); 00218 00219 00221 00241 statistics op_test(user_interaction & dialog, 00242 const archive_options_test & options, 00243 statistics * progressive_report); 00244 00245 00247 00255 bool get_children_of(user_interaction & dialog, 00256 const std::string & dir); 00257 00267 const std::vector<list_entry> get_children_in_table(const std::string & dir) const; 00268 00270 const entree_stats get_stats() const { if(cat == NULL) throw SRC_BUG; return cat->get_stats(); }; 00271 00274 void init_catalogue(user_interaction & dialog) const; 00275 00277 00285 const catalogue & get_catalogue() const; 00286 00288 const catalogue & get_catalogue(user_interaction & dialog) const; 00289 00291 00297 void drop_all_filedescriptors(); 00298 00300 00301 void drop_all_filedescriptors(user_interaction & dialog); 00302 00303 private: 00304 enum operation { oper_create, oper_isolate, oper_merge }; 00305 00306 pile stack; 00307 header_version ver; 00308 catalogue *cat; 00309 infinint local_cat_size; 00310 path *local_path; 00311 bool exploitable; //< is false if only the catalogue is available (for reference backup or isolation). 00312 bool lax_read_mode; //< whether the archive has been openned in lax mode (unused for creation/merging/isolation) 00313 bool sequential_read; //< whether the archive is read in sequential mode 00314 00315 void free(); 00316 catalogue & get_cat() const { if(cat == NULL) throw SRC_BUG; else return *cat; }; 00317 const header_version & get_header() const { return ver; }; 00318 const path & get_path() { if(local_path == NULL) throw SRC_BUG; else return *local_path; }; 00319 00320 bool get_sar_param(infinint & sub_file_size, infinint & first_file_size, infinint & last_file_size, 00321 infinint & total_file_number); 00322 infinint get_level2_size(); 00323 infinint get_cat_size() const { return local_cat_size; }; 00324 00325 statistics op_create_in(user_interaction & dialog, 00326 operation op, 00327 const path & fs_root, 00328 const path & sauv_path, 00329 archive *ref_arch, 00330 const mask & selection, 00331 const mask & subtree, 00332 const std::string & filename, 00333 const std::string & extension, 00334 bool allow_over, 00335 bool warn_over, 00336 bool info_details, 00337 const infinint & pause, 00338 bool empty_dir, 00339 compression algo, 00340 U_I compression_level, 00341 const infinint & file_size, 00342 const infinint & first_file_size, 00343 const mask & ea_mask, 00344 const std::string & execute, 00345 crypto_algo crypto, 00346 const secu_string & pass, 00347 U_32 crypto_size, 00348 const mask & compr_mask, 00349 const infinint & min_compr_size, 00350 bool nodump, 00351 const infinint & hourshift, 00352 bool empty, 00353 bool alter_atime, 00354 bool furtive_read_mode, 00355 bool same_fs, 00356 inode::comparison_fields what_to_check, 00357 bool snapshot, 00358 bool cache_directory_tagging, 00359 bool display_skipped, 00360 const infinint & fixed_date, 00361 const std::string & slice_permission, 00362 const std::string & slice_user_ownership, 00363 const std::string & slice_group_ownership, 00364 const infinint & repeat_count, 00365 const infinint & repeat_byte, 00366 bool add_marks_for_sequential_reading, 00367 bool security_check, 00368 const infinint & sparse_file_min_size, 00369 const std::string & user_comment, 00370 hash_algo hash, 00371 const infinint & slice_min_digits, 00372 const std::string & backup_hook_file_execute, 00373 const mask & backup_hook_file_mask, 00374 bool ignore_unknown, 00375 statistics * progressive_report); 00376 00377 void op_create_in_sub(user_interaction & dialog, //< interaction with user 00378 operation op, //< the filter operation to bind to 00379 const path & fs_root, //< root of the filesystem to act on 00380 const path & sauv_path_t, //< where to create the archive 00381 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) 00382 catalogue * ref_arch2, //< secondary catalogue used for merging, can be NULL if not used 00383 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) 00384 const mask & selection, //< filter on filenames 00385 const mask & subtree, //< filter on directory tree and filenames 00386 const std::string & filename, //< basename of the archive to create 00387 const std::string & extension, //< extension of the archives 00388 bool allow_over, //< whether to allow overwriting (of slices) 00389 const crit_action & overwrite, //< whether and how to allow overwriting (for files inside the archive) 00390 bool warn_over, //< whether to warn before overwriting 00391 bool info_details, //< whether to display detailed informations 00392 const infinint & pause, //< whether to pause between slices 00393 bool empty_dir, //< whether to store excluded dir as empty directories 00394 compression algo, //< compression algorithm 00395 U_I compression_level, //< compression level (range 1 to 9) 00396 const infinint & file_size, //< slice size 00397 const infinint & first_file_size, //< first slice size 00398 const mask & ea_mask, //< Extended Attribute to consider 00399 const std::string & execute, //< Command line to execute between slices 00400 crypto_algo crypto, //< crypt algorithm 00401 const secu_string & pass, //< password ("" for onfly request of password) 00402 U_32 crypto_size, //< size of crypto blocks 00403 const mask & compr_mask, //< files to compress 00404 const infinint & min_compr_size, //< file size under which to not compress files 00405 bool nodump, //< whether to consider the "nodump" filesystem flag 00406 const infinint & hourshift, //< hourshift (see man page -H option) 00407 bool empty, //< whether to make an "dry-run" execution 00408 bool alter_atime, //< whether to alter atime date (by opposition to ctime) when reading files 00409 bool furtive_read_mode, //< whether to neither alter atime nor ctome (if true alter_atime is ignored) 00410 bool same_fs, //< confin the files consideration to a single filesystem 00411 inode::comparison_fields what_to_check, //< fields to consider wien comparing inodes (see inode::comparison_fields enumeration) 00412 bool snapshot, //< make as if all file had not changed 00413 bool cache_directory_tagging, //< avoid saving directory which follow the cache directory tagging 00414 bool display_skipped, //< display skipped files for the operation 00415 bool keep_compressed, //< keep file compressed when merging 00416 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 00417 const std::string & slice_permission, //< permissions of slices that will be created 00418 const std::string & slice_user_ownership, //< user ownership of slices that will be created 00419 const std::string & slice_group_ownership, //< group ownership of slices that will be created 00420 const infinint & repeat_count, //< max number of retry to save a file that have changed while it was read for backup 00421 const infinint & repeat_byte, //< max amount of wasted data used to save a file that have changed while it was read for backup 00422 bool decremental, //< in the merging context only, whether to build a decremental backup from the two archives of reference 00423 bool add_marks_for_sequential_reading, //< whether to add marks for sequential reading 00424 bool security_check, //< whether to check for ctime change with no reason (rootkit ?) 00425 const infinint & sparse_file_min_size, //< starting which size to consider looking for holes in sparse files (0 for no detection) 00426 const std::string & user_comment, //< user comment to put in the archive 00427 hash_algo hash, //< whether to produce hash file, and which algo to use 00428 const infinint & slice_min_digits, //< minimum digit for slice number 00429 const std::string & backup_hook_file_execute, //< command to execute before and after files to backup 00430 const mask & backup_hook_file_mask, //< files elected to have a command executed before and after their backup 00431 bool ignore_unknown, //< whether to warn when an unknown inode type is met 00432 statistics * st_ptr); //< statistics must not be NULL ! 00433 00434 void disable_natural_destruction(); 00435 void enable_natural_destruction(); 00436 const label & get_layer1_data_name() const; 00437 const label & get_catalogue_data_name() const; 00438 bool only_contains_an_isolated_catalogue() const; //< true if the current archive only contains an isolated catalogue 00439 void check_against_isolation(user_interaction & dialog, bool lax) const; //< throw Erange exception if the archive only contains an isolated catalogue 00440 void check_header_version() const; 00441 const directory *get_dir_object(const std::string & dir) const; 00442 }; 00443 00444 } // end of namespace 00445 00446 #endif
1.7.6.1