Disk ARchive  2.5.18
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-2052 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21 
27 
29 
30 #ifndef FICHIER_GLOBAL_HPP
31 #define FICHIER_GLOBAL_HPP
32 
33 
34 #include "../my_config.h"
35 
36 extern "C"
37 {
38 #if HAVE_UNISTD_H
39 #include <unistd.h>
40 #endif
41 } // end extern "C"
42 
43 #include "integers.hpp"
44 #include "thread_cancellation.hpp"
45 #include "label.hpp"
46 #include "crc.hpp"
47 #include "user_interaction.hpp"
48 #include "mem_ui.hpp"
49 
50 #include <string>
51 
52 namespace libdar
53 {
54 
57 
59 
60  class fichier_global : public generic_file, public thread_cancellation, public mem_ui
61  {
62  public :
63  enum advise
64  {
65  advise_normal, //< no advise given by the application
66  advise_sequential, //< application expect to read the data sequentially
67  advise_random, //< application expect to read the data in random order
68  advise_noreuse, //< application does not expect to read the data more than once
69  advise_willneed, //< application expect to read the data again in near future
70  advise_dontneed //< application will not read the data in near future
71  };
72 
77  fichier_global(const user_interaction & dialog, gf_mode mode): generic_file(mode), mem_ui(dialog) {};
78  fichier_global(const fichier_global & ref) : generic_file(ref), thread_cancellation(ref), mem_ui(ref) {};
79 
80  // default assignment operator is fine here
81  // default destructor is fine too here
82 
84  virtual void change_ownership(const std::string & user, const std::string & group) = 0;
85 
87  virtual void change_permission(U_I perm) = 0;
88 
90  virtual infinint get_size() const = 0;
91 
93  virtual void fadvise(advise adv) const = 0;
94 
95  protected :
106  virtual U_I fichier_global_inherited_write(const char *a, U_I size) = 0;
107 
108 
119  virtual bool fichier_global_inherited_read(char *a, U_I size, U_I & read, std::string & message) = 0;
120 
121  private:
122 
123  // inherited from generic_file class and relocated as private methods
124  void inherited_write(const char *a, U_I size);
125  U_I inherited_read(char *a, U_I size);
126  };
127 
128 
130 
131 } // end of namespace
132 
133 #endif
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
are defined here basic integer types that tend to be portable
class crc definition, used to handle Cyclic Redundancy Checks
define the datastructure "label" used to identify slice membership to an archive
This is a pure virtual class that is used by libdar when interaction with the user is required...
U_I read(char *a, U_I size)
read data from the generic_file
gf_mode
generic_file openning modes
defines the interaction between libdar and the user.Three classes are defined
virtual bool fichier_global_inherited_read(char *a, U_I size, U_I &read, std::string &message)=0
virtual void change_permission(U_I perm)=0
change the permission of the file
abstraction of filesystem files for entrepot
to be able to cancel libdar operation while running in a given thread.the class thread_cancellation i...
virtual void change_ownership(const std::string &user, const std::string &group)=0
set the ownership of the file
mem_ui(const user_interaction &dialog)
constructor
Definition: mem_ui.hpp:62
generic_file(gf_mode m)
main constructor
class to be used as parent to provide checkpoints to inherited classes
thread_cancellation()
the constructor
virtual void fadvise(advise adv) const =0
set posix_fadvise for the whole file
fichier_global(const user_interaction &dialog, gf_mode mode)
this is the interface class from which all other data transfer classes inherit
class mem_ui to keep a copy of a user_interaction object
Definition: mem_ui.hpp:53
virtual U_I fichier_global_inherited_write(const char *a, U_I size)=0
the arbitrary large positive integer class
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
virtual infinint get_size() const =0
return the size of the file