Disk ARchive  2.5.16
Full featured and portable backup and archiving tool
entrepot.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 // $Id: entrepot.hpp,v 1.1 2012/04/27 11:24:30 edrusb Exp $
22 //
23 /*********************************************************************/
24 
25 
36 
38 
39 #ifndef ENTREPOT_HPP
40 #define ENTREPOT_HPP
41 
42 #include "../my_config.h"
43 
44 #include <string>
45 #include "infinint.hpp"
46 #include "generic_file.hpp"
47 #include "user_interaction.hpp"
48 #include "fichier_global.hpp"
49 #include "hash_fichier.hpp"
50 #include "etage.hpp"
51 #include "path.hpp"
52 #include "on_pool.hpp"
53 
54 namespace libdar
55 {
58 
60 
61  class entrepot : public on_pool
62  {
63  public:
64 
66  entrepot();
67 
69  virtual ~entrepot() {};
70 
72  bool operator == (const entrepot & ref) const { return get_url() == ref.get_url(); };
73 
74 
76  void set_location(const path & chemin);
77 
79  void set_root(const path & p_root) { if(p_root.is_relative()) throw Erange("entrepot::set_root", std::string(gettext("root's entrepot must be an absolute path: ")) + p_root.display()); root = p_root; };
80 
82  void set_user_ownership(const std::string & x_user) { user = x_user; };
83  void set_group_ownership(const std::string & x_group) { group = x_group; };
84 
85  const path & get_location() const { return where; }; //< retreives relative to root path the current location points to
86  const path & get_root() const { return root; }; //< retrieves the given root location
87  path get_full_path() const;
88  virtual std::string get_url() const = 0; //< defines an URL-like normalized full location of slices
89  const std::string & get_user_ownership() const { return user; };
90  const std::string & get_group_ownership() const { return group; };
91 
105  const std::string & filename,
106  gf_mode mode,
107  bool force_permission,
108  U_I permission,
109  bool fail_if_exists,
110  bool erase,
111  hash_algo algo) const;
112 
114  virtual void read_dir_reset() = 0;
115  virtual bool read_dir_next(std::string & filename) = 0;
116 
117  void unlink(const std::string & filename) const { inherited_unlink(filename); }; //< done this way for homogeneity with open/inherited_open
118 
119 
120  virtual entrepot *clone() const = 0;
121 
122  protected:
123  virtual fichier_global *inherited_open(user_interaction & dialog, //< for user interaction
124  const std::string & filename, //< filename to open
125  gf_mode mode, //< mode to use
126  bool force_permission, //< set the permission of the file to open
127  U_I permission, //< value of the permission to assign when force_permission is true
128  bool fail_if_exists, //< whether to fail if file exists (write mode)
129  bool erase) const = 0; //< whether to erase file if file already exists (write mode)
130 
131  virtual void inherited_unlink(const std::string & filename) const = 0;
132 
133  virtual void read_dir_flush() = 0; //< ends the read_dir_next, (no more entry available)
134 
135  private:
136  path where;
137  path root;
138  std::string user;
139  std::string group;
140  };
141 
143 
144 } // end of namespace
145 
146 #endif
bool is_relative() const
whether the path is relative or absolute (= start with a /)
Definition: path.hpp:98
virtual void read_dir_reset()=0
routines to read existing files in the current directory (see set_location() / set_root() methods) ...
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
This is a pure virtual class that is used by libdar when interaction with the user is required...
gf_mode
generic_file openning modes
entrepot()
constructor
void set_root(const path &p_root)
defines the root to use if set_location is given a relative path
Definition: entrepot.hpp:79
bool operator==(const entrepot &ref) const
says whether two entrepot objects points to the same location
Definition: entrepot.hpp:72
defines the interaction between libdar and the user.Three classes are defined
void set_location(const path &chemin)
defines the directory where to proceed to future open() – this is a "chdir" semantics ...
here is the definition of the path classthe path class handle path and provide several operation on t...
definition of the etage structure is done here
fichier_global * open(user_interaction &dialog, const std::string &filename, gf_mode mode, bool force_permission, U_I permission, bool fail_if_exists, bool erase, hash_algo algo) const
class fichier_global definition. This class is a pure virtual class class fichier_global is an abstra...
abstraction of filesystem files for entrepot
switch module to limitint (32 ou 64 bits integers) or infinint
class hash_fichier definition.This is an inherited class from class fichier Objects of that class are...
exception used to signal range error
Definition: erreurs.hpp:179
this is the base class of object that can be allocated on a memory pool
void set_user_ownership(const std::string &x_user)
set default ownership for files to be created thanks to the open() methods
Definition: entrepot.hpp:82
virtual ~entrepot()
destructor
Definition: entrepot.hpp:69
the Entrepot interface
Definition: entrepot.hpp:61
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
std::string display() const
convert back a path to a string
the class path is here to manipulate paths in the Unix notation: using&#39;/&#39;
Definition: path.hpp:50