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

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

fichier_local.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
26
27 #ifndef FICHIER_LOCAL_HPP
28 #define FICHIER_LOCAL_HPP
29
30
31 #include "../my_config.h"
32
33 extern "C"
34 {
35 #if HAVE_UNISTD_H
36 #include <unistd.h>
37 #endif
38 } // end extern "C"
39
40 #include "integers.hpp"
41 #include "thread_cancellation.hpp"
42 #include "label.hpp"
43 #include "crc.hpp"
44 #include "user_interaction.hpp"
45 #include "mem_ui.hpp"
46 #include "fichier_global.hpp"
47
48 #include <string>
49
50 namespace libdar
51 {
52
55
56
58
59 class fichier_local : public fichier_global
60 {
61 public :
62
63 // constructors
64
65 fichier_local(user_interaction & dialog,
66 const std::string & chemin,
67 gf_mode m,
68 U_I permission,
69 bool fail_if_exists,
70 bool erase,
71 bool furtive_mode);
72 fichier_local(const std::string & chemin, bool furtive_mode = false); // builds a read-only object
73 fichier_local(const fichier_local & ref) : fichier_global(ref) { copy_from(ref); };
74
75 // assignment operator
76 const fichier_local & operator = (const fichier_local & ref) { detruit(); copy_parent_from(ref); copy_from(ref); return *this; };
77
78 // destructor
79 ~fichier_local() { detruit(); };
80
81
83 virtual void change_ownership(const std::string & user, const std::string & group);
84
86 virtual void change_permission(U_I perm);
87
89 infinint get_size() const;
90
92 void fadvise(advise adv) const;
93
94 // inherited from generic_file
95 bool skippable(skippability direction, const infinint & amount) { return true; };
96 bool skip(const infinint & pos);
97 bool skip_to_eof();
98 bool skip_relative(S_I x);
99 infinint get_position() const;
100
104 S_I give_fd_and_terminate() { int ret = filedesc; filedesc = -1; terminate(); return ret; };
105
106 protected :
107 // inherited from generic_file grand-parent class
108 void inherited_read_ahead(const infinint & amount) {}; // nothing done, calling readahead(2) could be added in the future
109 void inherited_sync_write() { fsync(); };
110 void inherited_flush_read() {}; // nothing stored in transit in this object
111 void inherited_terminate() { if(adv == advise_dontneed) fadvise(adv); };
112
113 // inherited from fichier_global parent class
114 U_I fichier_global_inherited_write(const char *a, U_I size);
115 bool fichier_global_inherited_read(char *a, U_I size, U_I & read, std::string & message);
116
117 private :
118 S_I filedesc;
119 advise adv;
120
121 void open(const std::string & chemin,
122 gf_mode m,
123 U_I permission,
124 bool fail_if_exists,
125 bool erase,
126 bool furtive_mode);
127
128 void copy_from(const fichier_local & ref);
129 void copy_parent_from(const fichier_local & ref);
130 void detruit() { if(filedesc >= 0) close(filedesc); filedesc = -1; };
131 int advise_to_int(advise arg) const;
132
134
138 void fsync() const;
139
140 };
141
143
144 } // end of namespace
145
146 #endif
mem_ui.hpp
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
libdar::fichier_local::inherited_read_ahead
void inherited_read_ahead(const infinint &amount)
Definition: fichier_local.hpp:108
integers.hpp
are defined here basic integer types that tend to be portable
crc.hpp
class crc definition, used to handle Cyclic Redundancy Checks
label.hpp
define the datastructure "label" used to identify slice membership to an archive
libdar::user_interaction
This is a pure virtual class that is used by libdar when interaction with the user is required...
Definition: user_interaction.hpp:98
libdar::generic_file::read
U_I read(char *a, U_I size)
read data from the generic_file
libdar::fichier_local
filesystem local files
Definition: fichier_local.hpp:59
libdar::gf_mode
gf_mode
generic_file openning modes
Definition: generic_file.hpp:77
libdar::fichier_local::get_position
infinint get_position() const
get the current read/write position
libdar::fichier_local::inherited_sync_write
void inherited_sync_write()
write down any pending data
Definition: fichier_local.hpp:109
libdar::generic_file::terminate
void terminate() const
destructor-like call, except that it is allowed to throw exceptions
user_interaction.hpp
defines the interaction between libdar and the user.Three classes are defined
libdar::fichier_local::inherited_flush_read
void inherited_flush_read()
Definition: fichier_local.hpp:110
fichier_global.hpp
class fichier_global definition. This class is a pure virtual class class fichier_global is an abstra...
libdar::fichier_global
abstraction of filesystem files for entrepot
Definition: fichier_global.hpp:60
thread_cancellation.hpp
to be able to cancel libdar operation while running in a given thread.the class thread_cancellation i...
libdar::fichier_local::skippable
bool skippable(skippability direction, const infinint &amount)
Definition: fichier_local.hpp:95
libdar::fichier_local::change_ownership
virtual void change_ownership(const std::string &user, const std::string &group)
set the ownership of the file
libdar::fichier_local::fichier_global_inherited_write
U_I fichier_global_inherited_write(const char *a, U_I size)
libdar::fichier_local::skip
bool skip(const infinint &pos)
libdar::fichier_global::fichier_global
fichier_global(const user_interaction &dialog, gf_mode mode)
Definition: fichier_global.hpp:77
libdar::fichier_local::fadvise
void fadvise(advise adv) const
set posix_fadvise for the whole file
libdar::fichier_local::skip_relative
bool skip_relative(S_I x)
skip relatively to the current position
libdar::infinint
the arbitrary large positive integer class
Definition: real_infinint.hpp:59
libdar::fichier_local::give_fd_and_terminate
S_I give_fd_and_terminate()
Definition: fichier_local.hpp:104
libdar::fichier_local::inherited_terminate
void inherited_terminate()
destructor-like call, except that it is allowed to throw exceptions
Definition: fichier_local.hpp:111
libdar::fichier_local::fichier_global_inherited_read
bool fichier_global_inherited_read(char *a, U_I size, U_I &read, std::string &message)
libdar::fichier_local::skip_to_eof
bool skip_to_eof()
skip to the end of file
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
libdar::fichier_local::change_permission
virtual void change_permission(U_I perm)
change the permission of the file
libdar::fichier_local::get_size
infinint get_size() const
return the size of the file