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

Loading...
Searching...
No Matches
tuyau_global.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
34
35#ifndef TUYAU_GLOBAL_HPP
36#define TUYAU_GLOBAL_HPP
37
38#include "../my_config.h"
39#include "tuyau.hpp"
40#include "fichier_global.hpp"
41
42namespace libdar
43{
44
47
49
50 class tuyau_global: public fichier_global
51 {
52 public:
54
59 tuyau_global(const std::shared_ptr<user_interaction> & dialog,
60 fichier_global *x_ptr);
61
63 tuyau_global(tuyau_global & ref) = delete;
64
66 tuyau_global(tuyau_global && ref) = delete;
67
69 tuyau_global & operator = (const tuyau_global & ref) = delete;
70
72 tuyau_global & operator = (tuyau_global && ref) = delete;
73
75 ~tuyau_global() { detruit(); };
76
77 // inherited from fichier_global
78
79 virtual void change_ownership(const std::string & user, const std::string & group) override { ptr->change_ownership(user, group); };
80 virtual void change_permission(U_I perm) override { ptr->change_permission(perm); };
81 virtual infinint get_size() const override { return ptr->get_size(); };
82 virtual void fadvise(advise adv) const override { ptr->fadvise(adv); };
83
84
85 // inherited from generic_file grand-parent class
86
87 virtual bool skippable(skippability direction, const infinint & amount) override { return ptr->skippable(direction, amount); };
88 virtual bool skip(const infinint & pos) override;
89 virtual bool skip_to_eof() override;
90 virtual bool skip_relative(S_I x) override;
91 virtual bool truncatable(const infinint & pos) const override { return ptr->truncatable(pos); };
92 virtual infinint get_position() const override { return current_pos; };
93
94
95 protected:
96
97 // inherited from fichier_global
98
99 virtual U_I fichier_global_inherited_write(const char *a, U_I size) override;
100 virtual bool fichier_global_inherited_read(char *a, U_I size, U_I & read, std::string & message) override;
101
102 // inherted from generic_file
103 virtual void inherited_read_ahead(const infinint & amount) override { ptr->read_ahead(amount); };
104 virtual void inherited_truncate(const infinint & pos) override { ptr->truncate(pos); };
105 virtual void inherited_sync_write() override { ptr->sync_write(); };
106 virtual void inherited_flush_read() override { ptr->flush_read(); };
107 virtual void inherited_terminate() override { ptr->terminate(); };
108
109
110 private:
111 static const U_I buffer_size = 102400;
112
113 fichier_global *ptr;
114 infinint current_pos;
115 char buffer[buffer_size];
116
117 void detruit();
118 U_I read_and_drop(U_I bytes);
119 };
120
122
123} // end of namespace
124
125#endif
126
libdar::fichier_global
abstraction of filesystem files for entrepot
Definition fichier_global.hpp:59
libdar::fichier_global::advise
advise
Definition fichier_global.hpp:62
libdar::fichier_global::get_size
virtual infinint get_size() const =0
return the size of the file
libdar::fichier_global::change_permission
virtual void change_permission(U_I perm)=0
change the permission of the file
libdar::fichier_global::fadvise
virtual void fadvise(advise adv) const =0
set posix_fadvise for the whole file
libdar::fichier_global::change_ownership
virtual void change_ownership(const std::string &user, const std::string &group)=0
set the ownership of the file
libdar::generic_file::truncatable
virtual bool truncatable(const infinint &pos) const =0
whether the implementation is able to truncate to the given position
libdar::generic_file::terminate
void terminate()
destructor-like call, except that it is allowed to throw exceptions
libdar::generic_file::truncate
virtual void truncate(const infinint &pos)
truncate file at the given offset
libdar::generic_file::skippable
virtual bool skippable(skippability direction, const infinint &amount)=0
whether the implementation is able to skip
libdar::generic_file::read_ahead
void read_ahead(const infinint &amount)
libdar::generic_file::flush_read
void flush_read()
be ready to read at current position, reseting all pending data for reading, cached and in compressio...
libdar::generic_file::sync_write
void sync_write()
write any pending data
libdar::generic_file::read
virtual U_I read(char *a, U_I size) override
read data from the generic_file inherited from proto_generic_file
libdar::infinint
the arbitrary large positive integer class
Definition real_infinint.hpp:62
libdar::tuyau_global
the tuyau_global provides skip()/get_position() features on top of pipe-like object
Definition tuyau_global.hpp:51
libdar::tuyau_global::buffer
char buffer[buffer_size]
to skip emulation done by reading data
Definition tuyau_global.hpp:115
libdar::tuyau_global::ptr
fichier_global * ptr
points to the underlying object
Definition tuyau_global.hpp:113
libdar::tuyau_global::tuyau_global
tuyau_global(tuyau_global &ref)=delete
copy constructor
libdar::tuyau_global::~tuyau_global
~tuyau_global()
destructor
Definition tuyau_global.hpp:75
libdar::tuyau_global::truncatable
virtual bool truncatable(const infinint &pos) const override
whether the implementation is able to truncate to the given position
Definition tuyau_global.hpp:91
libdar::tuyau_global::inherited_sync_write
virtual void inherited_sync_write() override
write down any pending data
Definition tuyau_global.hpp:105
libdar::tuyau_global::skip_relative
virtual bool skip_relative(S_I x) override
skip relatively to the current position
libdar::tuyau_global::fichier_global_inherited_write
virtual U_I fichier_global_inherited_write(const char *a, U_I size) override
replaces generic_file::inherited_write() method, to allow the return of partial writings
libdar::tuyau_global::get_position
virtual infinint get_position() const override
get the current read/write position
Definition tuyau_global.hpp:92
libdar::tuyau_global::change_permission
virtual void change_permission(U_I perm) override
change the permission of the file
Definition tuyau_global.hpp:80
libdar::tuyau_global::operator=
tuyau_global & operator=(const tuyau_global &ref)=delete
assignment operator
libdar::tuyau_global::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 tuyau_global.hpp:103
libdar::tuyau_global::get_size
virtual infinint get_size() const override
return the size of the file
Definition tuyau_global.hpp:81
libdar::tuyau_global::tuyau_global
tuyau_global(const std::shared_ptr< user_interaction > &dialog, fichier_global *x_ptr)
constructor
libdar::tuyau_global::change_ownership
virtual void change_ownership(const std::string &user, const std::string &group) override
set the ownership of the file
Definition tuyau_global.hpp:79
libdar::tuyau_global::skippable
virtual bool skippable(skippability direction, const infinint &amount) override
whether the implementation is able to skip
Definition tuyau_global.hpp:87
libdar::tuyau_global::skip_to_eof
virtual bool skip_to_eof() override
skip to the end of file
libdar::tuyau_global::inherited_flush_read
virtual void inherited_flush_read() override
reset internal engine, flush caches in order to read the data at current position
Definition tuyau_global.hpp:106
libdar::tuyau_global::fadvise
virtual void fadvise(advise adv) const override
set posix_fadvise for the whole file
Definition tuyau_global.hpp:82
libdar::tuyau_global::inherited_terminate
virtual void inherited_terminate() override
destructor-like call, except that it is allowed to throw exceptions
Definition tuyau_global.hpp:107
libdar::tuyau_global::fichier_global_inherited_read
virtual bool fichier_global_inherited_read(char *a, U_I size, U_I &read, std::string &message) override
replaces generic_file::inherited_read() method, to allow the return of partial reading
libdar::tuyau_global::current_pos
infinint current_pos
record the current offset
Definition tuyau_global.hpp:114
libdar::tuyau_global::inherited_truncate
virtual void inherited_truncate(const infinint &pos) override
truncate file at the give offset
Definition tuyau_global.hpp:104
libdar::tuyau_global::skip
virtual bool skip(const infinint &pos) override
skip at the absolute position
libdar::tuyau_global::tuyau_global
tuyau_global(tuyau_global &&ref)=delete
move constructor
fichier_global.hpp
class fichier_global definition. This class is a pure virtual class class fichier_global is an abstra...
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
tuyau.hpp
defines the implementation of pipe under the generic_file interface.