![]() |
Disk ARchive
2.5.2
Full featured and portable backup and archiving tool
|
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 HEADER_HPP 00028 #define HEADER_HPP 00029 00030 #include "../my_config.h" 00031 00032 #include "infinint.hpp" 00033 #include "generic_file.hpp" 00034 #include "user_interaction.hpp" 00035 #include "tlv_list.hpp" 00036 #include "label.hpp" 00037 #include "on_pool.hpp" 00038 00039 #include <vector> 00040 00041 namespace libdar 00042 { 00043 00046 00047 const U_32 SAUV_MAGIC_NUMBER = 123; // Why "SAUV_..." because SAUV was the name of DAR much before its first release :-) 00048 00049 typedef U_32 magic_number; 00050 00051 enum flag_type 00052 { 00053 flag_type_terminal = 'T', 00054 flag_type_non_terminal = 'N', 00055 flag_type_located_at_end_of_slice = 'E' // since archive format version 8 00056 }; 00057 00058 00060 00067 00068 class header : public on_pool 00069 { 00070 public: 00071 // constructors & Co. 00072 00073 header(); 00074 header(const header & ref) { copy_from(ref); }; 00075 const header & operator = (const header & ref) { free_pointers(); copy_from(ref); return *this; }; 00076 ~header() { free_pointers(); }; 00077 00078 // global methods 00079 00080 void read(user_interaction & ui, generic_file & f, bool lax = false ); 00081 void write(user_interaction &, generic_file & f) const; 00082 00084 00092 static U_I min_size() { return sizeof(magic_number) + sizeof(label) + 2*sizeof(char); }; 00093 00094 00095 // fields access methods 00096 00097 magic_number & get_set_magic() { return magic; }; 00098 label & get_set_internal_name() { return internal_name; }; 00099 char & get_set_flag() { return flag; }; 00100 label & get_set_data_name() { return data_name; }; 00101 00102 bool get_first_slice_size(infinint & size) const; 00103 void set_first_slice_size(const infinint & size); 00104 void unset_first_slice_size() { if(first_size != nullptr) { delete first_size; first_size = nullptr; } }; 00105 00106 bool get_slice_size(infinint & size) const; 00107 void set_slice_size(const infinint & size); 00108 void unset_slice_size() { if(slice_size != nullptr) { delete slice_size; slice_size = nullptr; } }; 00109 00110 bool is_old_header() const { return old_header; }; 00111 void set_format_07_compatibility() { old_header = true; }; 00112 00113 private: 00114 magic_number magic; //< constant string for all Dar archives 00115 label internal_name; //< constant string for all slices of a given archive (computed based on date and pid) 00116 label data_name; //< constant string for a set of data (constant with dar_xform, used to link isolated catalogue to its original data) 00117 char flag; //< whether slice is the last of the archive or not 00118 infinint *first_size; //< size of the first slice 00119 infinint *slice_size; //< size of slices (except first slice if specified else and last if not fulfilled) 00120 bool old_header; //< true if the header has been read from an old archive (before release 2.4.0, format 07 and below) and if true when writing, create an old slice header (compatible with format 07). 00121 00122 void copy_from(const header & ref); 00123 void free_pointers(); 00124 void fill_from(user_interaction & ui, const tlv_list & list); 00125 tlv_list build_tlv_list(user_interaction & ui) const; 00126 }; 00127 00129 00130 } // end of namespace 00131 00132 #endif 00133