Disk ARchive  2.6.8
Full featured and portable backup and archiving tool
entrepot_local.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2020 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 : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21 
33 
34 #ifndef ENTREPOT_LOCAL_HPP
35 #define ENTREPOT_LOCAL_HPP
36 
37 #include "../my_config.h"
38 
39 #include <string>
40 #include "user_interaction.hpp"
41 #include "entrepot.hpp"
42 #include "fichier_global.hpp"
43 #include "etage.hpp"
44 
45 namespace libdar
46 {
49 
53 
54  class entrepot_local : public entrepot
55  {
56  public:
57  entrepot_local(const std::string & user, const std::string & group, bool x_furtive_mode);
58  entrepot_local(const entrepot_local & ref): entrepot(ref) { copy_from(ref); };
59  entrepot_local(entrepot_local && ref) noexcept: entrepot(std::move(ref)) { nullifyptr(); move_from(std::move(ref)); };
60  entrepot_local & operator = (const entrepot_local & ref);
61  entrepot_local & operator = (entrepot_local && ref) noexcept { entrepot::operator = (std::move(ref)); move_from(std::move(ref)); return *this; };
62  ~entrepot_local() { detruit(); };
63 
64  virtual std::string get_url() const override { return std::string("file://") + get_full_path().display(); };
65 
66  virtual void read_dir_reset() const override;
67  virtual bool read_dir_next(std::string & filename) const override;
68 
69  virtual entrepot *clone() const override { return new (std::nothrow) entrepot_local(*this); };
70 
71  protected:
72  virtual fichier_global *inherited_open(const std::shared_ptr<user_interaction> & dialog,
73  const std::string & filename,
74  gf_mode mode,
75  bool force_permission,
76  U_I permission,
77  bool fail_if_exists,
78  bool erase) const override;
79 
80  virtual void inherited_unlink(const std::string & filename) const override;
81  virtual void read_dir_flush() override { detruit(); };
82 
83  private:
84  bool furtive_mode;
85  etage *contents;
86 
87  void nullifyptr() noexcept { contents = nullptr; };
88  void copy_from(const entrepot_local & ref) { furtive_mode = ref.furtive_mode; contents = nullptr; };
89  void move_from(entrepot_local && ref) noexcept { std::swap(contents, ref.contents), std::swap(furtive_mode, ref.furtive_mode); };
90  void detruit() { if(contents != nullptr) { delete contents; contents = nullptr; } };
91  };
92 
94 
95 } // end of namespace
96 
97 #endif
libdar::entrepot::operator=
entrepot & operator=(const entrepot &ref)=default
assignment operator
user_interaction.hpp
defines the interaction interface between libdar and users.
libdar::gf_mode
gf_mode
generic_file openning modes
Definition: gf_mode.hpp:43
libdar::entrepot_local::read_dir_reset
virtual void read_dir_reset() const override
routines to read existing files in the current directory (see set_location() / set_root() methods)
libdar::entrepot::get_full_path
virtual path get_full_path() const
returns the full path of location
libdar::entrepot::entrepot
entrepot()
constructor
fichier_global.hpp
class fichier_global definition. This class is a pure virtual class class fichier_global is an abstra...
entrepot.hpp
defines the entrepot interface. Entrepot interface defines a generic way to interact with files (slic...
libdar::path::display
std::string display() const
convert back a path to a string
libdar::entrepot_local::clone
virtual entrepot * clone() const override
generate a clone of "this"
Definition: entrepot_local.hpp:69
libdar::entrepot_local
Definition: entrepot_local.hpp:54
libdar::entrepot
the Entrepot interface
Definition: entrepot.hpp:56
etage.hpp
definition of the etage structure is done here
libdar::fichier_global
abstraction of filesystem files for entrepot
Definition: fichier_global.hpp:58
libdar::entrepot_local::get_url
virtual std::string get_url() const override
full path of current directory + anything necessary to provide URL formated information
Definition: entrepot_local.hpp:64
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:46