Disk ARchive
2.8.5
Full featured and portable backup and archiving tool
Toggle main menu visibility
Loading...
Searching...
No Matches
src
libdar
header.hpp
Go to the documentation of this file.
1
/*********************************************************************/
2
// dar - disk archive - a backup/restoration program
3
// Copyright (C) 2002-2026 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
//
19
// to contact the author, see the AUTHOR file
20
/*********************************************************************/
21
25
26
27
#ifndef HEADER_HPP
28
#define HEADER_HPP
29
30
#include "
../my_config.h
"
31
32
#include "
infinint.hpp
"
33
#include "
generic_file.hpp
"
34
#include "
user_interaction.hpp
"
35
#include "
tlv_list.hpp
"
36
#include "
label.hpp
"
37
38
namespace
libdar
39
{
40
43
44
const
U_32 SAUV_MAGIC_NUMBER = 123;
// Why "SAUV_..." because SAUV was the name of DAR much before its first release :-)
45
46
using
magic_number = U_32;
47
48
enum
flag_type
49
{
50
flag_type_terminal =
'T'
,
51
flag_type_non_terminal =
'N'
,
52
flag_type_located_at_end_of_slice =
'E'
// since archive format version 8
53
};
54
55
57
64
65
class
header
66
{
67
public
:
68
// constructors & Co.
69
70
header();
71
header(
const
header & ref) { copy_from(ref); };
72
header(header && ref)
noexcept
{ nullifyptr(); move_from(std::move(ref)); };
73
header & operator = (
const
header & ref) { free_pointers(); copy_from(ref);
return
*
this
; };
74
header & operator = (header && ref)
noexcept
{ move_from(std::move(ref));
return
*
this
; };
75
~header() { free_pointers(); };
76
77
// global methods
78
79
void
read(
user_interaction
& ui,
generic_file
& f,
bool
lax =
false
);
80
void
write(
user_interaction
&,
generic_file
& f)
const
;
81
83
91
static
U_I
min_size
() {
return
sizeof
(magic_number) + label::common_size() + 2*
sizeof
(char); };
92
93
94
// fields access methods
95
96
magic_number & get_set_magic() {
return
magic
; };
97
label & get_set_internal_name() {
return
internal_name
; };
98
char
& get_set_flag() {
return
flag
; };
99
label & get_set_data_name() {
return
data_name
; };
100
101
bool
get_first_slice_size(infinint & size)
const
;
102
void
set_first_slice_size(
const
infinint & size);
103
void
unset_first_slice_size() {
if
(
first_size
!=
nullptr
) {
delete
first_size
;
first_size
=
nullptr
; } };
104
105
bool
get_slice_size(infinint & size)
const
;
106
void
set_slice_size(
const
infinint & size);
107
void
unset_slice_size() {
if
(
slice_size
!=
nullptr
) {
delete
slice_size
;
slice_size
=
nullptr
; } };
108
109
bool
is_old_header()
const
{
return
old_header
; };
110
void
set_format_07_compatibility() {
old_header
=
true
; };
111
112
private
:
113
magic_number
magic
;
114
label
internal_name
;
115
label
data_name
;
116
char
flag
;
117
infinint
*
first_size
;
118
infinint
*
slice_size
;
119
bool
old_header
;
120
121
void
nullifyptr() noexcept {
first_size
=
slice_size
=
nullptr
; };
122
void
copy_from(
const
header
& ref);
123
void
move_from(
header
&& ref)
noexcept
;
124
void
free_pointers();
125
void
fill_from(
user_interaction
& ui,
const
tlv_list & list);
126
tlv_list build_tlv_list(
user_interaction
& ui)
const
;
127
};
128
130
131
}
// end of namespace
132
133
#endif
134
libdar::generic_file
this is the interface class from which all other data transfer classes inherit
Definition
generic_file.hpp:77
libdar::header
this class manages the header of each slice
Definition
header.hpp:66
libdar::header::old_header
bool old_header
true if the header has been read from an old archive (before release 2.4.0, format 07 and below) and ...
Definition
header.hpp:119
libdar::header::slice_size
infinint * slice_size
size of slices (except first slice if specified else and last if not fulfilled)
Definition
header.hpp:118
libdar::header::internal_name
label internal_name
constant string for all slices of a given archive (computed based on date and pid)
Definition
header.hpp:114
libdar::header::flag
char flag
whether slice is the last of the archive or not
Definition
header.hpp:116
libdar::header::magic
magic_number magic
constant string for all Dar archives
Definition
header.hpp:113
libdar::header::data_name
label data_name
constant string for a set of data (constant with dar_xform, used to link isolated catalogue to its or...
Definition
header.hpp:115
libdar::header::first_size
infinint * first_size
size of the first slice
Definition
header.hpp:117
libdar::header::min_size
static U_I min_size()
minimal size of a header in an archive
Definition
header.hpp:91
libdar::infinint
the arbitrary large positive integer class
Definition
real_infinint.hpp:62
libdar::label
manage label data structure used in archive slice headers
Definition
label.hpp:43
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:58
generic_file.hpp
class generic_file is defined here as well as class fichier
infinint.hpp
switch module to limitint (32 ou 64 bits integers) or infinint
label.hpp
define the datastructure "label" used to identify slice membership to an archive
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition
archive.hpp:47
tlv_list.hpp
List of Generic Type Length Value data structures.
user_interaction.hpp
defines the interaction interface between libdar and users.
Generated on
for Disk ARchive by
1.17.0