Disk ARchive  2.7.15
Full featured and portable backup and archiving tool
fichier_global.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2024 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 
35 extern "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 
50 namespace 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  {
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
abstraction of filesystem files for entrepot
virtual U_I inherited_read(char *a, U_I size) override
implementation of read() operation
@ advise_random
application expect to read the data in random order
@ advise_noreuse
application does not expect to read the data more than once
@ advise_willneed
application expect to read the data again in near future
@ advise_dontneed
application will not read the data in near future
@ advise_sequential
application expect to read the data sequentially
@ advise_normal
no advise given by the application
bool disk_full
whether user refused to continue due to disk being full
virtual infinint get_size() const =0
return the size of the file
fichier_global(const fichier_global &ref)=default
copy constructor
fichier_global & operator=(const fichier_global &ref)=default
assignment operator
virtual void change_permission(U_I perm)=0
change the permission of the file
virtual void fadvise(advise adv) const =0
set posix_fadvise for the whole file
fichier_global(fichier_global &&ref) noexcept=default
move constructor
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
virtual void change_ownership(const std::string &user, const std::string &group)=0
set the ownership of the file
virtual void inherited_write(const char *a, U_I size) override
implementation of the write() operation
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
fichier_global(const std::shared_ptr< user_interaction > &dialog, gf_mode mode)
constructor
this is the interface class from which all other data transfer classes inherit
virtual U_I read(char *a, U_I size) override
read data from the generic_file inherited from proto_generic_file
the arbitrary large positive integer class
class mem_ui to keep a copy of a user_interaction object
Definition: mem_ui.hpp:55
class to be used as parent to provide checkpoints to inherited classes
class generic_file is defined here as well as class fichier
gf_mode
generic_file openning modes
Definition: gf_mode.hpp:44
are defined here basic integer types that tend to be portable
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
to be able to cancel libdar operation while running in a given thread.
defines the interaction interface between libdar and users.