Disk ARchive: fichier_global.hpp Source File

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

Loading...
Searching...
No Matches
fichier_global.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
28
29#ifndef FICHIER_GLOBAL_HPP
30#define FICHIER_GLOBAL_HPP
31
32
33#include "../my_config.h"
34
35extern "C"
36{
37#if HAVE_UNISTD_H
38#include <unistd.h>
39#endif
40} // end extern "C"
41
42#include "integers.hpp"
43#include "generic_file.hpp"
44#include "thread_cancellation.hpp"
45#include "user_interaction.hpp"
46#include "mem_ui.hpp"
47
48#include <string>
49
50namespace libdar
51{
52
55
57
58 class fichier_global : public generic_file, public thread_cancellation, public mem_ui
59 {
60 public :
61 enum advise
62 {
63 advise_normal,
64 advise_sequential,
65 advise_random,
66 advise_noreuse,
67 advise_willneed,
68 advise_dontneed
69 };
70
72
76 fichier_global(const std::shared_ptr<user_interaction> & dialog,
77 gf_mode mode): generic_file(mode),
78 mem_ui(dialog),
79 disk_full(false) {};
80
82 fichier_global(const fichier_global & ref) = default;
83
85 fichier_global(fichier_global && ref) noexcept = default;
86
88 fichier_global & operator = (const fichier_global & ref) = default;
89
91 fichier_global & operator = (fichier_global && ref) noexcept = default;
92
93 // destructor
94 ~fichier_global() = default;
95
97 virtual void change_ownership(const std::string & user, const std::string & group) = 0;
98
100 virtual void change_permission(U_I perm) = 0;
101
103 virtual infinint get_size() const = 0;
104
106 virtual void fadvise(advise adv) const = 0;
107
108 protected :
110
119 virtual U_I fichier_global_inherited_write(const char *a, U_I size) = 0;
120
121
123
132 virtual bool fichier_global_inherited_read(char *a, U_I size, U_I & read, std::string & message) = 0;
133
134 private:
135 bool disk_full;
136
137 // inherited from generic_file class and relocated as private methods
138 virtual void inherited_write(const char *a, U_I size) override;
139 virtual U_I inherited_read(char *a, U_I size) override;
140 };
141
142
144
145} // end of namespace
146
147#endif
libdar::fichier_global::inherited_read
virtual U_I inherited_read(char *a, U_I size) override
implementation of read() operation
libdar::fichier_global::advise
advise
Definition fichier_global.hpp:62
libdar::fichier_global::advise_random
@ advise_random
application expect to read the data in random order
Definition fichier_global.hpp:65
libdar::fichier_global::advise_noreuse
@ advise_noreuse
application does not expect to read the data more than once
Definition fichier_global.hpp:66
libdar::fichier_global::advise_willneed
@ advise_willneed
application expect to read the data again in near future
Definition fichier_global.hpp:67
libdar::fichier_global::advise_dontneed
@ advise_dontneed
application will not read the data in near future
Definition fichier_global.hpp:68
libdar::fichier_global::advise_sequential
@ advise_sequential
application expect to read the data sequentially
Definition fichier_global.hpp:64
libdar::fichier_global::advise_normal
@ advise_normal
no advise given by the application
Definition fichier_global.hpp:63
libdar::fichier_global::disk_full
bool disk_full
whether user refused to continue due to disk being full
Definition fichier_global.hpp:135
libdar::fichier_global::get_size
virtual infinint get_size() const =0
return the size of the file
libdar::fichier_global::fichier_global
fichier_global(const fichier_global &ref)=default
copy constructor
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::operator=
fichier_global & operator=(const fichier_global &ref)=default
assignment operator
libdar::fichier_global::fichier_global
fichier_global(fichier_global &&ref) noexcept=default
move constructor
libdar::fichier_global::fichier_global_inherited_write
virtual U_I fichier_global_inherited_write(const char *a, U_I size)=0
replaces generic_file::inherited_write() method, to allow the return of partial writings
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::fichier_global::inherited_write
virtual void inherited_write(const char *a, U_I size) override
implementation of the write() operation
libdar::fichier_global::fichier_global_inherited_read
virtual bool fichier_global_inherited_read(char *a, U_I size, U_I &read, std::string &message)=0
replaces generic_file::inherited_read() method, to allow the return of partial reading
libdar::fichier_global::fichier_global
fichier_global(const std::shared_ptr< user_interaction > &dialog, gf_mode mode)
constructor
Definition fichier_global.hpp:76
libdar::generic_file::generic_file
generic_file(gf_mode m)
main constructor
Definition generic_file.hpp:80
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::mem_ui::mem_ui
mem_ui(const std::shared_ptr< user_interaction > &dialog)
constructor
libdar::thread_cancellation::thread_cancellation
thread_cancellation()
the constructor
generic_file.hpp
class generic_file is defined here as well as class fichier
libdar::gf_mode
gf_mode
generic_file openning modes
Definition gf_mode.hpp:44
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
thread_cancellation.hpp
to be able to cancel libdar operation while running in a given thread.
user_interaction.hpp
defines the interaction interface between libdar and users.