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

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

trivial_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 TRIVIAL_SAR_HPP
27 #define TRIVIAL_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
54
55 class trivial_sar : public generic_file , public contextual, protected mem_ui
56 {
57 public:
59 trivial_sar(const user_interaction & dialog, //< how to interact with the user
60 gf_mode open_mode, //< read_write or write_only are the only acceptable values
61 const std::string & base_name, //< archive basename to create
62 const std::string & extension, //< archive extension
63 const entrepot & where, //< where to store the archive
64 const label & internal_nale, //< tag common to all slices of the archive
65 const label & data_name, //< tag that follows the data when archive is dar_xform'ed
66 const std::string & execute, //< command line to execute at end of slice creation
67 bool allow_over, //< whether to allow overwriting
68 bool warn_over, //< whether to warn before overwriting
69 bool force_permission, //< whether to enforce slice permission or not
70 U_I permission, //< value of permission to use if permission enforcement is used
71 hash_algo x_hash, //< whether to build a hash of the slice, and which algo to use for that
72 const infinint & min_digits, //< is the minimum number of digits the slices number is stored with in the filename
73 bool format_07_compatible); //< build a slice header backward compatible with 2.3.x
74
75
77 trivial_sar(const user_interaction & dialog, //< how to interact with the user
78 const std::string & pipename, //< if set to '-' the data are read from standard input, else the given file is expected to be named pipe to read data from
79 bool lax); //< whether to be laxist or follow the normal and strict controlled procedure
80
81
83 trivial_sar(const user_interaction & dialog,
84 generic_file * f, //< in case of exception the generic_file "f" is not released, this is the duty of the caller to do so, else (success), the object becomes owned by the trivial_sar and must not be released by the caller.
85 const label & internal_name,
86 const label & data_name,
87 bool format_07_compatible,
88 const std::string & execute);
89
91 trivial_sar(const trivial_sar & ref) : generic_file(ref), mem_ui(ref) { throw SRC_BUG; };
92
94 ~trivial_sar();
95
96 const trivial_sar & operator = (const trivial_sar & ref) { throw SRC_BUG; };
97 bool skippable(skippability direction, const infinint & amount) { return reference->skippable(direction, amount); };
98 bool skip(const infinint & pos);
99 bool skip_to_eof() { if(is_terminated()) throw SRC_BUG; return reference->skip_to_eof(); };
100 bool skip_relative(S_I x);
101 infinint get_position() const { return cur_pos; };
102
103 // contextual inherited method
104 bool is_an_old_start_end_archive() const { return old_sar; };
105 const label & get_data_name() const { return of_data_name; };
106
108 const infinint & get_slice_header_size() const { return offset; };
109
110 protected:
111 void inherited_read_ahead(const infinint & amount) { reference->read_ahead(amount); };
112 U_I inherited_read(char *a, U_I size);
113 void inherited_write(const char *a, U_I size);
114 void inherited_sync_write() {};
115 void inherited_flush_read() {};
116 void inherited_terminate();
117
118 private:
119 generic_file *reference; //< points to the underlying data, owned by "this"
120 infinint offset; //< offset to apply to get the first byte of data out of SAR headers
121 infinint cur_pos; //< current position as returned by get_position()
122 infinint end_of_slice; //< when end of slice/archive is met, there is an offset by 1 compared to the offset of reference. end_of_slice is set to 1 in that situation, else it is always equal to zero
123 std::string hook; //< command to execute after slice writing (not used in read-only mode)
124 std::string base; //< basename of the archive (used for string susbstitution in hook)
125 std::string ext; //< extension of the archive (used for string substitution in hook)
126 label of_data_name; //< archive's data name
127 bool old_sar; //< true if the read sar has an old header (format <= "07") or the to be written is must keep a version 07 format.
128 infinint min_digits; //< minimum number of digits in slice name
129 std::string hook_where; //< what value to use for %p subsitution in hook
130
131 void init(const label & internal_name); //< write the slice header and set the offset field (write mode), or (read-mode), reads the slice header an set offset field
132
133 void where_am_i();
134 };
135
136
138
139 extern std::string sar_make_filename(const std::string & base_name, const infinint & num, const infinint & min_digits, const std::string & ext);
140
142
143 } // end of namespace
144
145 #endif
entrepot.hpp
defines the entrepot interface. Entrepot interface defines a generic way to interact with files (slic...
libdar::trivial_sar::inherited_read_ahead
void inherited_read_ahead(const infinint &amount)
Definition: trivial_sar.hpp:111
libdar::trivial_sar::get_slice_header_size
const infinint & get_slice_header_size() const
size of the slice header
Definition: trivial_sar.hpp:108
libdar::trivial_sar::inherited_terminate
void inherited_terminate()
destructor-like call, except that it is allowed to throw exceptions
libdar::trivial_sar::inherited_sync_write
void inherited_sync_write()
write down any pending data
Definition: trivial_sar.hpp:114
integers.hpp
are defined here basic integer types that tend to be portable
libdar::trivial_sar::skip_to_eof
bool skip_to_eof()
skip to the end of file
Definition: trivial_sar.hpp:99
tools.hpp
a set of general purpose routines
generic_file.hpp
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
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::trivial_sar::inherited_write
void inherited_write(const char *a, U_I size)
implementation of the write() operation
libdar::generic_file::read_ahead
virtual void read_ahead(const infinint &amount)
libdar::trivial_sar::trivial_sar
trivial_sar(const trivial_sar &ref)
copy constructor (disabled)
Definition: trivial_sar.hpp:91
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::trivial_sar::skip_relative
bool skip_relative(S_I x)
skip relatively to the current position
libdar::generic_file::is_terminated
bool is_terminated() const
Definition: generic_file.hpp:316
libdar::trivial_sar::trivial_sar
trivial_sar(const user_interaction &dialog, gf_mode open_mode, const std::string &base_name, const std::string &extension, const entrepot &where, const label &internal_nale, const label &data_name, const std::string &execute, bool allow_over, bool warn_over, bool force_permission, U_I permission, hash_algo x_hash, const infinint &min_digits, bool format_07_compatible)
constructor to build a new single sliced archive
libdar::trivial_sar
Definition: trivial_sar.hpp:55
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::trivial_sar::~trivial_sar
~trivial_sar()
destructor
infinint.hpp
switch module to limitint (32 ou 64 bits integers) or infinint
libdar::trivial_sar::inherited_read
U_I inherited_read(char *a, U_I size)
implementation of read() operation
libdar::trivial_sar::skippable
bool skippable(skippability direction, const infinint &amount)
Definition: trivial_sar.hpp:97
libdar::sar_make_filename
std::string sar_make_filename(const std::string &base_name, const infinint &num, const infinint &min_digits, const std::string &ext)
return the name of a slice given the base_name, slice number and extension
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::hash_algo
hash_algo
Definition: hash_fichier.hpp:57
libdar::trivial_sar::inherited_flush_read
void inherited_flush_read()
Definition: trivial_sar.hpp:115
libdar::infinint
the arbitrary large positive integer class
Definition: real_infinint.hpp:59
libdar::trivial_sar::get_position
infinint get_position() const
get the current read/write position
Definition: trivial_sar.hpp:101
libdar::trivial_sar::skip
bool skip(const infinint &pos)
libdar::generic_file::skip_to_eof
virtual bool skip_to_eof()=0
skip to the end of file
libdar::entrepot
the Entrepot interface
Definition: entrepot.hpp:61
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
libdar::generic_file::skippable
virtual bool skippable(skippability direction, const infinint &amount)=0