| Disk ARchive 2.5.10 Full featured and portable backup and archiving tool

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

sar.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
25
26 #ifndef SAR_HPP
27 #define SAR_HPP
28
29 #include "../my_config.h"
30
31 #include <string>
32 #include "infinint.hpp"
33 #include "generic_file.hpp"
34 #include "header.hpp"
35 #include "path.hpp"
36 #include "integers.hpp"
37 #include "entrepot.hpp"
38 #include "tools.hpp"
39 #include "slice_layout.hpp"
40
41 namespace libdar
42 {
43 // contextual is defined in generic_file module
44
47
49
54 class sar : public generic_file, public contextual, protected mem_ui
55 {
56 public:
57
59
72 sar(const user_interaction & dialog,
73 const std::string & base_name,
74 const std::string & extension,
75 const entrepot & where,
76 bool by_the_end,
77 const infinint & x_min_digits,
78 bool lax = false,
79 const std::string & execute = "");
80
81
83
104 sar(const user_interaction & dialog,
105 gf_mode open_mode,
106 const std::string & base_name,
107 const std::string & extension,
108 const infinint & file_size,
109 const infinint & first_file_size,
110 bool x_warn_overwrite,
111 bool x_allow_overwrite,
112 const infinint & pause,
113 const entrepot & where,
114 const label & internal_name,
115 const label & data_name,
116 bool force_permission,
117 U_I permission,
118 hash_algo x_hash,
119 const infinint & x_min_digits,
120 bool format_07_compatible,
121 const std::string & execute = "");
122
124
125 sar(const sar & ref) : generic_file(ref), mem_ui(ref) { throw Efeature("class sar's copy constructor is not implemented"); };
126
128 ~sar();
129
130 // inherited from generic_file
131 bool skippable(skippability direction, const infinint & amount);
132 bool skip(const infinint &pos);
133 bool skip_to_eof();
134 bool skip_relative(S_I x);
135 infinint get_position() const;
136
137 // informational routines
138 const slice_layout & get_slicing() const { return slicing; };
139 bool get_total_file_number(infinint &num) const { num = of_last_file_num; return of_last_file_known; };
140 bool get_last_file_size(infinint &num) const { num = of_last_file_size; return of_last_file_known; };
141
142 // disable execution of user command when destroying the current object
143 void disable_natural_destruction() { natural_destruction = false; };
144
145 // enable back execution of user command when destroying the current object
146 void enable_natural_destruction() { natural_destruction = true; };
147
148 // true if sar's header is from an old archive format (<= "07")
149 bool is_an_old_start_end_archive() const { return slicing.older_sar_than_v8; };
150
151 // return the internal_name used to link slices toghether
152 const label & get_internal_name_used() const { return of_internal_name; };
153
154 // return the data_name used to link slices toghether
155 const label & get_data_name() const { return of_data_name; };
156
157 const entrepot *get_entrepot() const { return entr; };
158
160 const infinint & get_first_slice_header_size() const { return slicing.first_slice_header; };
161
163 const infinint & get_non_first_slice_header_size() const { return slicing.other_slice_header; };
164
165 protected :
166 void inherited_read_ahead(const infinint & amount);
167 U_I inherited_read(char *a, U_I size);
168 void inherited_write(const char *a, U_I size);
169 void inherited_sync_write() {}; // nothing to do
170 void inherited_flush_read() {}; // nothing to do
171 void inherited_terminate();
172
173 private :
174 entrepot *entr; //< where are stored slices
175 std::string base; //< archive base name
176 std::string ext; //< archive extension
177 std::string hook; //< command line to execute between slices
178 slice_layout slicing; //< slice layout
179 infinint file_offset; //< current reading/writing position in the current slice (relative to the whole slice file, including headers)
180 hash_algo hash; //< whether to build a hashing when creating slices, and if so, which algorithm to use
181 infinint min_digits; //< minimum number of digits the slices number is stored with in the filename
182 bool natural_destruction; //< whether to execute commands between slices on object destruction
183 // these following variables are modified by open_file / open_file_init
184 // else the are used only for reading
185 infinint of_current; //< number of the open slice
186 infinint size_of_current; //< size of the current slice (used in reading mode only)
187 infinint of_max_seen; //< highest slice number seen so far
188 bool of_last_file_known; //< whether the T terminal slice has been met
189 infinint of_last_file_num; //< number of the last slice (if met)
190 infinint of_last_file_size; //< size of the last slice (if met)
191 label of_internal_name; //< internal name shared in all slice header
192 label of_data_name; //< internal name linked to data (transparent to dar_xform and used by isolated catalogue as reference)
193 bool force_perm; //< true if any future slice has its permission to be set explicitely
194 U_I perm; //< if force_perm is true, value to use for slice permission
195 fichier_global *of_fd; //< file object currently openned
196 char of_flag; //< flags of the open file
197 bool initial; //< do not launch hook command-line during sar initialization
198 // these are the option flags
199 bool opt_warn_overwrite; //< a warning must be issued before overwriting a slice
200 bool opt_allow_overwrite; //< is slice overwriting allowed
201 //
202 infinint pause; //< do we pause between slices
203 bool lax; //< whether to try to go further reading problems
204 infinint to_read_ahead; //< amount of data to read ahead for next slices
205
206 bool skip_forward(U_I x); //< skip forward in sar global contents
207 bool skip_backward(U_I x); //< skip backward in sar global contents
208 void close_file(bool terminal); //< close current openned file, adding (in write mode only) a terminal mark (last slice) or not
209 void open_readonly(const std::string & fic, const infinint &num); //< open file of name "filename" for read only "num" is the slice number
210 void open_writeonly(const std::string & fic, const infinint &num); //< open file of name "filename" for write only "num" is the slice number
211 void open_file_init(); //< initialize some of_* fields
212 void open_file(infinint num); //< close current slice and open the slice 'num'
213 void set_offset(infinint offset); //< skip to current slice relative offset
214 void open_last_file(); //< open the last slice, ask the user, test, until last slice available
215 bool is_current_eof_a_normal_end_of_slice() const; //< return true if current reading position is at end of slice
216 infinint bytes_still_to_read_in_slice() const; //< returns the number of bytes expected before the end of slice
217 header make_write_header(const infinint &num, char flag);
218
219 // function to lauch the eventually existing command to execute after/before each slice
220 void hook_execute(const infinint &num);
221 };
222
224
225 } // end of namespace
226
227 #endif
libdar::sar::inherited_flush_read
void inherited_flush_read()
Definition: sar.hpp:170
entrepot.hpp
defines the entrepot interface. Entrepot interface defines a generic way to interact with files (slic...
libdar::sar::sar
sar(const sar &ref)
the destructor
Definition: sar.hpp:125
integers.hpp
are defined here basic integer types that tend to be portable
tools.hpp
a set of general purpose routines
libdar::sar::skip_to_eof
bool skip_to_eof()
skip to the end of file
generic_file.hpp
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
libdar::sar::inherited_sync_write
void inherited_sync_write()
write down any pending data
Definition: sar.hpp:169
libdar::user_interaction
This is a pure virtual class that is used by libdar when interaction with the user is required...
Definition: user_interaction.hpp:98
libdar::sar::get_non_first_slice_header_size
const infinint & get_non_first_slice_header_size() const
get the non first slice header
Definition: sar.hpp:163
libdar::sar
Sar class stands for Segmentation And Reassembly class.
Definition: sar.hpp:54
libdar::sar::inherited_read
U_I inherited_read(char *a, U_I size)
implementation of read() operation
libdar::sar::~sar
~sar()
destructor
libdar::gf_mode
gf_mode
generic_file openning modes
Definition: generic_file.hpp:77
slice_layout.hpp
object describing the slicing of an archive
libdar::sar::get_first_slice_header_size
const infinint & get_first_slice_header_size() const
get the first slice header
Definition: sar.hpp:160
libdar::sar::inherited_read_ahead
void inherited_read_ahead(const infinint &amount)
libdar::sar::skippable
bool skippable(skippability direction, const infinint &amount)
header.hpp
slice header structure is defined here
path.hpp
here is the definition of the path classthe path class handle path and provide several operation on t...
libdar::Efeature
exception used when a requested feature is not (yet) implemented
Definition: erreurs.hpp:206
libdar::fichier_global
abstraction of filesystem files for entrepot
Definition: fichier_global.hpp:60
libdar::sar::inherited_terminate
void inherited_terminate()
destructor-like call, except that it is allowed to throw exceptions
infinint.hpp
switch module to limitint (32 ou 64 bits integers) or infinint
libdar::generic_file
this is the interface class from which all other data transfer classes inherit
Definition: generic_file.hpp:100
libdar::mem_ui
class mem_ui to keep a copy of a user_interaction object
Definition: mem_ui.hpp:53
libdar::sar::skip
bool skip(const infinint &pos)
libdar::hash_algo
hash_algo
Definition: hash_fichier.hpp:57
libdar::sar::inherited_write
void inherited_write(const char *a, U_I size)
implementation of the write() operation
libdar::infinint
the arbitrary large positive integer class
Definition: real_infinint.hpp:59
libdar::sar::skip_relative
bool skip_relative(S_I x)
skip relatively to the current position
libdar::header
this class manages the header of each slice
Definition: header.hpp:68
libdar::sar::sar
sar(const user_interaction &dialog, const std::string &base_name, const std::string &extension, const entrepot &where, bool by_the_end, const infinint &x_min_digits, bool lax=false, const std::string &execute="")
this constructor reads data from a set of slices
libdar::entrepot
the Entrepot interface
Definition: entrepot.hpp:61
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
libdar::sar::get_position
infinint get_position() const
get the current read/write position