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

Loading...
Searching...
No Matches
zapette.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2025 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
32
33#ifndef ZAPETTE_HPP
34#define ZAPETTE_HPP
35
36#include "../my_config.h"
37#include "infinint.hpp"
38#include "generic_file.hpp"
39#include "integers.hpp"
40#include "mem_ui.hpp"
41#include "contextual.hpp"
42
43 namespace libdar
44{
45
46
49
51
55
56 class zapette : public generic_file, public contextual, protected mem_ui
57 {
58 public:
59
61
66 zapette(const std::shared_ptr<user_interaction> & dialog, generic_file *input, generic_file *output, bool by_the_end);
67 zapette(const zapette & ref) = default;
68 zapette(zapette && ref) noexcept = default;
69 zapette & operator = (const zapette & ref) = default;
70 zapette & operator = (zapette && ref) noexcept = default;
71 ~zapette();
72
73 // inherited methods from generic_file
74 virtual bool skippable(skippability direction, const infinint & amount) override { return true; };
75 virtual bool skip(const infinint &pos) override;
76 virtual bool skip_to_eof() override { if(is_terminated()) throw SRC_BUG; position = file_size; return true; };
77 virtual bool skip_relative(S_I x) override;
78 virtual bool truncatable(const infinint & pos) const override { return false; };
79 virtual infinint get_position() const override { if(is_terminated()) throw SRC_BUG; return position; };
80
81 // overwritten inherited methods from contextual
82 virtual void set_info_status(const std::string & s) override;
83 virtual bool is_an_old_start_end_archive() const override;
84 virtual const label & get_data_name() const override;
85
89 infinint get_first_slice_header_size() const;
90
94 infinint get_non_first_slice_header_size() const;
95
96 protected:
97 virtual void inherited_read_ahead(const infinint & amount) override {}; // optimization will be done when zapette will use the messaging_encode/decode exchange format
98 virtual U_I inherited_read(char *a, U_I size) override;
99 virtual void inherited_write(const char *a, U_I size) override;
100 virtual void inherited_truncate(const infinint & pos) override { throw SRC_BUG; }; // read only object
101 virtual void inherited_sync_write() override {};
102 virtual void inherited_flush_read() override {};
103 virtual void inherited_terminate() override;
104
105 private:
106 generic_file *in, *out;
107 infinint position, file_size;
108 char serial_counter;
109
111
127
128 void make_transfert(U_16 size, const infinint &offset, char *data, const std::string & info, S_I & lu, infinint & arg) const;
129 };
130
132
133} // end of namespace
134
135#endif
libdar::contextual
the contextual class adds the information of phases in the generic_file
Definition contextual.hpp:74
libdar::generic_file
this is the interface class from which all other data transfer classes inherit
Definition generic_file.hpp:77
libdar::generic_file::is_terminated
bool is_terminated() const
Definition generic_file.hpp:327
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::mem_ui
class mem_ui to keep a copy of a user_interaction object
Definition mem_ui.hpp:55
libdar::zapette
zapette emulate a file that is remotely controlled by slave_zapette
Definition zapette.hpp:57
libdar::zapette::inherited_read_ahead
virtual void inherited_read_ahead(const infinint &amount) override
tells the object that several calls to read() will follow to probably obtain at least the given amoun...
Definition zapette.hpp:97
libdar::zapette::zapette
zapette(const std::shared_ptr< user_interaction > &dialog, generic_file *input, generic_file *output, bool by_the_end)
zapette constructor
libdar::zapette::get_first_slice_header_size
infinint get_first_slice_header_size() const
libdar::zapette::get_data_name
virtual const label & get_data_name() const override
obtain the data_name of the archive (label associated with the archive's data)
libdar::zapette::make_transfert
void make_transfert(U_16 size, const infinint &offset, char *data, const std::string &info, S_I &lu, infinint &arg) const
wrapped formatted method to communicate with the slave_zapette located behind the pair of pipes (= tu...
libdar::zapette::inherited_read
virtual U_I inherited_read(char *a, U_I size) override
implementation of read() operation
libdar::zapette::skip_relative
virtual bool skip_relative(S_I x) override
skip relatively to the current position
libdar::zapette::truncatable
virtual bool truncatable(const infinint &pos) const override
whether the implementation is able to truncate to the given position
Definition zapette.hpp:78
libdar::zapette::is_an_old_start_end_archive
virtual bool is_an_old_start_end_archive() const override
returns whether the archive is a old archive (format < 8)
libdar::zapette::inherited_terminate
virtual void inherited_terminate() override
destructor-like call, except that it is allowed to throw exceptions
libdar::zapette::inherited_flush_read
virtual void inherited_flush_read() override
reset internal engine, flush caches in order to read the data at current position
Definition zapette.hpp:102
libdar::zapette::inherited_sync_write
virtual void inherited_sync_write() override
write down any pending data
Definition zapette.hpp:101
libdar::zapette::inherited_write
virtual void inherited_write(const char *a, U_I size) override
implementation of the write() operation
libdar::zapette::skip
virtual bool skip(const infinint &pos) override
skip at the absolute position
libdar::zapette::set_info_status
virtual void set_info_status(const std::string &s) override
defines the new contextual value
libdar::zapette::skippable
virtual bool skippable(skippability direction, const infinint &amount) override
whether the implementation is able to skip
Definition zapette.hpp:74
libdar::zapette::skip_to_eof
virtual bool skip_to_eof() override
skip to the end of file
Definition zapette.hpp:76
libdar::zapette::inherited_truncate
virtual void inherited_truncate(const infinint &pos) override
truncate file at the give offset
Definition zapette.hpp:100
libdar::zapette::get_non_first_slice_header_size
infinint get_non_first_slice_header_size() const
libdar::zapette::get_position
virtual infinint get_position() const override
get the current read/write position
Definition zapette.hpp:79
contextual.hpp
class contextual adds the information of phases in the generic_file
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
integers.hpp
are defined here basic integer types that tend to be portable
mem_ui.hpp
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
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