Loading...
Searching...
No Matches
zapette.hpp
Go to the documentation of this file.
/*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2025 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 ZAPETTE_HPP
#define ZAPETTE_HPP
#include "../my_config.h"
#include "infinint.hpp"
#include "generic_file.hpp"
#include "integers.hpp"
#include "mem_ui.hpp"
#include "contextual.hpp"
namespace libdar
{
class zapette : public generic_file, public contextual, protected mem_ui
{
public:
zapette(const std::shared_ptr<user_interaction> & dialog, generic_file *input, generic_file *output, bool by_the_end);
zapette(const zapette & ref) = default;
zapette(zapette && ref) noexcept = default;
zapette & operator = (const zapette & ref) = default;
zapette & operator = (zapette && ref) noexcept = default;
~zapette();
// inherited methods from generic_file
virtual bool skippable(skippability direction, const infinint & amount) override { return true; };
virtual bool skip(const infinint &pos) override;
virtual bool skip_to_eof() override { if(is_terminated()) throw SRC_BUG; position = file_size; return true; };
virtual bool skip_relative(S_I x) override;
virtual bool truncatable(const infinint & pos) const override { return false; };
virtual infinint get_position() const override { if(is_terminated()) throw SRC_BUG; return position; };
// overwritten inherited methods from contextual
virtual void set_info_status(const std::string & s) override;
virtual bool is_an_old_start_end_archive() const override;
virtual const label & get_data_name() const override;
infinint get_first_slice_header_size() const;
infinint get_non_first_slice_header_size() const;
protected:
virtual void inherited_read_ahead(const infinint & amount) override {}; // optimization will be done when zapette will use the messaging_encode/decode exchange format
virtual U_I inherited_read(char *a, U_I size) override;
virtual void inherited_write(const char *a, U_I size) override;
virtual void inherited_truncate(const infinint & pos) override { throw SRC_BUG; }; // read only object
virtual void inherited_sync_write() override {};
virtual void inherited_flush_read() override {};
virtual void inherited_terminate() override;
private:
generic_file *in, *out;
infinint position, file_size;
char serial_counter;
void make_transfert(U_16 size, const infinint &offset, char *data, const std::string & info, S_I & lu, infinint & arg) const;
};
} // end of namespace
#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