Disk ARchive  2.5.10
Full featured and portable backup and archiving tool
generic_to_global_file.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 
30 
31 #ifndef GENERIC_TO_GLOBAL_FILE_HPP
32 #define GENERIC_TO_GLOBAL_FILE_HPP
33 
34 #include "fichier_global.hpp"
35 #include "memory_file.hpp"
36 #include "storage.hpp"
37 
38 namespace libdar
39 {
40 
43 
44  class generic_to_global_file : public fichier_global
45  {
46  public:
47 
53  generic_to_global_file(user_interaction & dialog, generic_file *d, gf_mode mode): fichier_global(dialog, mode) { if(d == nullptr) throw SRC_BUG; if(d->get_mode() != gf_read_write && d->get_mode() != mode) throw SRC_BUG; data = d; };
54 
55  // virtual method inherited from generic_file
56  bool skippable(skippability direction, const infinint & amount) { return data->skippable(direction, amount); }
57  bool skip(const infinint & pos) { return data->skip(pos); };
58  bool skip_to_eof() { return data->skip_to_eof(); };
59  bool skip_relative(S_I x) { return data->skip_relative(x); };
60  infinint get_position() const { return data->get_position(); };
61 
62 
63  // virtual method inherited from fichier_global
64  void change_ownership(const std::string & user, const std::string & group) {};
65  void change_permission(U_I perm) {};
66  infinint get_size() const { return data->get_position(); }; //< yes, this is the drawback of this template class convertion, get_size() does not return the real size of the object
67  void fadvise(advise adv) const {};
68 
69 
70  protected:
71 
72  // virtual method inherited from generic_file
73  void inherited_read_ahead(const infinint & amount) {}; // no optimization can be done here, we rely on the OS here
74  void inherited_sync_write() {};
75  void inherited_flush_read() {};
76  void inherited_terminate() {};
77 
78  // inherited from fichier_global
79  U_I fichier_global_inherited_write(const char *a, U_I size) { data->write(a, size); return size; };
80  bool fichier_global_inherited_read(char *a, U_I size, U_I & read, std::string & message) { read = data->read(a, size); message = "THIS IS A BUG IN GENERIC_TO_GLOBAL_FILE, PLEASE REPORT TO THE MAINTAINER!"; return true; };
81 
82  private:
83  generic_file *data;
84  };
85 
87 
88 } // end of namespace
89 
90 #endif
contains a class that permits arbitrary large data storage
gf_mode
generic_file openning modes
Memory_file is a generic_file class that only uses virtual memory.
class fichier_global definition. This class is a pure virtual class class fichier_global is an abstra...
generic_file(gf_mode m)
main constructor
fichier_global(const user_interaction &dialog, gf_mode mode)
read and write access
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47