Loading...
Searching...
No Matches
header.hpp
Go to the documentation of this file.
/*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2024 Denis Corbin
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// to contact the author, see the AUTHOR file
/*********************************************************************/
#ifndef HEADER_HPP
#define HEADER_HPP
#include "../my_config.h"
#include "infinint.hpp"
#include "generic_file.hpp"
#include "user_interaction.hpp"
#include "tlv_list.hpp"
#include "label.hpp"
namespace libdar
{
const U_32 SAUV_MAGIC_NUMBER = 123; // Why "SAUV_..." because SAUV was the name of DAR much before its first release :-)
using magic_number = U_32;
enum flag_type
{
flag_type_terminal = 'T',
flag_type_non_terminal = 'N',
flag_type_located_at_end_of_slice = 'E' // since archive format version 8
};
class header
{
public:
// constructors & Co.
header();
header(const header & ref) { copy_from(ref); };
header(header && ref) noexcept { nullifyptr(); move_from(std::move(ref)); };
header & operator = (const header & ref) { free_pointers(); copy_from(ref); return *this; };
header & operator = (header && ref) noexcept { move_from(std::move(ref)); return *this; };
~header() { free_pointers(); };
// global methods
void read(user_interaction & ui, generic_file & f, bool lax = false );
void write(user_interaction &, generic_file & f) const;
static U_I min_size() { return sizeof(magic_number) + label::common_size() + 2*sizeof(char); };
// fields access methods
magic_number & get_set_magic() { return magic; };
label & get_set_internal_name() { return internal_name; };
char & get_set_flag() { return flag; };
label & get_set_data_name() { return data_name; };
bool get_first_slice_size(infinint & size) const;
void set_first_slice_size(const infinint & size);
void unset_first_slice_size() { if(first_size != nullptr) { delete first_size; first_size = nullptr; } };
bool get_slice_size(infinint & size) const;
void set_slice_size(const infinint & size);
void unset_slice_size() { if(slice_size != nullptr) { delete slice_size; slice_size = nullptr; } };
bool is_old_header() const { return old_header; };
void set_format_07_compatibility() { old_header = true; };
private:
magic_number magic;
label internal_name;
label data_name;
char flag;
infinint *first_size;
infinint *slice_size;
bool old_header;
void nullifyptr() noexcept { first_size = slice_size = nullptr; };
void copy_from(const header & ref);
void move_from(header && ref) noexcept;
void free_pointers();
void fill_from(user_interaction & ui, const tlv_list & list);
tlv_list build_tlv_list(user_interaction & ui) const;
};
} // end of namespace
#endif
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:47
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
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.