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

Loading...
Searching...
No Matches
entrepot_local.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2025 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, see the AUTHOR file
20/*********************************************************************/
21
26
27#ifndef ENTREPOT_LOCAL_HPP
28#define ENTREPOT_LOCAL_HPP
29
30#include "../my_config.h"
31
32#include <string>
33#include "user_interaction.hpp"
34#include "entrepot.hpp"
35#include "fichier_global.hpp"
36#include "etage.hpp"
37
38 namespace libdar
39{
42
46
47 class entrepot_local : public entrepot
48 {
49 public:
50 entrepot_local(const std::string & user, const std::string & group, bool x_furtive_mode);
51 entrepot_local(const entrepot_local & ref): entrepot(ref) { copy_from(ref); };
52 entrepot_local(entrepot_local && ref) noexcept: entrepot(std::move(ref)) { nullifyptr(); move_from(std::move(ref)); };
53 entrepot_local & operator = (const entrepot_local & ref);
54 entrepot_local & operator = (entrepot_local && ref) noexcept { entrepot::operator = (std::move(ref)); move_from(std::move(ref)); return *this; };
55 ~entrepot_local() { detruit(); };
56
57 virtual std::string get_url() const override { return std::string("file://") + get_full_path().display(); };
58
59 virtual void read_dir_reset() const override;
60 virtual bool read_dir_next(std::string & filename) const override;
61
62 virtual entrepot *clone() const override { return new (std::nothrow) entrepot_local(*this); };
63
64 protected:
65 virtual fichier_global *inherited_open(const std::shared_ptr<user_interaction> & dialog,
66 const std::string & filename,
67 gf_mode mode,
68 bool force_permission,
69 U_I permission,
70 bool fail_if_exists,
71 bool erase) const override;
72
73 virtual void inherited_unlink(const std::string & filename) const override;
74 virtual void read_dir_flush() override { detruit(); };
75
76 private:
77 bool furtive_mode;
78 etage *contents;
79
80 void nullifyptr() noexcept { contents = nullptr; };
81 void copy_from(const entrepot_local & ref) { furtive_mode = ref.furtive_mode; contents = nullptr; };
82 void move_from(entrepot_local && ref) noexcept { std::swap(contents, ref.contents), std::swap(furtive_mode, ref.furtive_mode); };
83 void detruit() { if(contents != nullptr) { delete contents; contents = nullptr; } };
84 };
85
87
88} // end of namespace
89
90#endif
libdar::entrepot_local
Definition entrepot_local.hpp:48
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_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:57
libdar::entrepot_local::clone
virtual entrepot * clone() const override
generate a clone of "this"
Definition entrepot_local.hpp:62
libdar::entrepot
the Entrepot interface
Definition entrepot.hpp:56
libdar::entrepot::get_full_path
virtual path get_full_path() const
returns the full path of location
libdar::entrepot::entrepot
entrepot()
constructor
libdar::entrepot::operator=
entrepot & operator=(const entrepot &ref)=default
assignment operator
libdar::fichier_global
abstraction of filesystem files for entrepot
Definition fichier_global.hpp:59
libdar::path::display
std::string display() const
convert back a path to a string
entrepot.hpp
defines the entrepot interface.
etage.hpp
definition of the etage structure is done here
fichier_global.hpp
class fichier_global definition. This class is a pure virtual class class fichier_global is an abstra...
libdar::gf_mode
gf_mode
generic_file openning modes
Definition gf_mode.hpp:44
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47
user_interaction.hpp
defines the interaction interface between libdar and users.