Disk ARchive 2.7.14
Full featured and portable backup and archiving tool
Loading...
Searching...
No Matches
src/libdar/entrepot_local.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2024 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
38namespace 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
virtual void read_dir_reset() const override
routines to read existing files in the current directory (see set_location() / set_root() methods)
virtual std::string get_url() const override
full path of current directory + anything necessary to provide URL formated information
virtual entrepot * clone() const override
generate a clone of "this"
virtual path get_full_path() const
returns the full path of location
entrepot()
constructor
entrepot & operator=(const entrepot &ref)=default
assignment operator
abstraction of filesystem files for entrepot
std::string display() const
convert back a path to a string
gf_mode
generic_file openning modes
include macro defined by the configure script and some specific additional ones
libdar namespace encapsulate all libdar symbols
defines the entrepot interface.
definition of the etage structure is done here
class fichier_global definition. This class is a pure virtual class class fichier_global is an abstra...
defines the interaction interface between libdar and users.