| Disk ARchive 2.8.6 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-2026 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
52
56 entrepot_local(const std::string & user, const std::string & group, bool x_furtive_mode);
57 entrepot_local(const entrepot_local & ref): entrepot(ref) { copy_from(ref); };
58 entrepot_local(entrepot_local && ref) noexcept: entrepot(std::move(ref)) { nullifyptr(); move_from(std::move(ref)); };
59 entrepot_local & operator = (const entrepot_local & ref);
60 entrepot_local & operator = (entrepot_local && ref) noexcept { entrepot::operator = (std::move(ref)); move_from(std::move(ref)); return *this; };
61 ~entrepot_local() { detruit(); };
62
63 virtual std::string get_url() const override { return std::string("file://") + get_full_path().display(); };
64
67 virtual void read_dir_reset() const override { read_dir_reset_dirinfo(); };
68 virtual bool read_dir_next(std::string & filename) const override;
69 virtual void read_dir_reset_dirinfo() const override;
70 virtual bool read_dir_next_dirinfo(std::string & filename, inode_type & tp) const override;
71
72 virtual void create_dir(const std::string & dirname, U_I permission) override;
73
74 virtual entrepot *clone() const override { return new (std::nothrow) entrepot_local(*this); };
75
76
77
78 protected:
79 virtual fichier_global *inherited_open(const std::shared_ptr<user_interaction> & dialog,
80 const std::string & filename,
81 gf_mode mode,
82 bool force_permission,
83 U_I permission,
84 bool fail_if_exists,
85 bool erase) const override;
86
87 virtual void inherited_unlink(const std::string & filename) const override;
88 virtual void read_dir_flush() const override { detruit(); };
89
90 private:
91 bool furtive_mode;
92 mutable etage *contents;
93
94 void nullifyptr() noexcept { contents = nullptr; };
95 void copy_from(const entrepot_local & ref) { furtive_mode = ref.furtive_mode; contents = nullptr; };
96 void move_from(entrepot_local && ref) noexcept { std::swap(contents, ref.contents), std::swap(furtive_mode, ref.furtive_mode); };
97 void detruit() const { if(contents != nullptr) { delete contents; contents = nullptr; } };
98 };
99
101
102} // end of namespace
103
104#endif
libdar::entrepot_local
Definition entrepot_local.hpp:48
libdar::entrepot_local::read_dir_reset
virtual void read_dir_reset() const override
Definition entrepot_local.hpp:67
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:63
libdar::entrepot_local::read_dir_next
virtual bool read_dir_next(std::string &filename) const override
read the next filename of the current directory
libdar::entrepot_local::read_dir_reset_dirinfo
virtual void read_dir_reset_dirinfo() const override
routines to read existing files with dir information
libdar::entrepot_local::entrepot_local
entrepot_local(const std::string &user, const std::string &group, bool x_furtive_mode)
constructor
libdar::entrepot_local::create_dir
virtual void create_dir(const std::string &dirname, U_I permission) override
create a new directory in the current directory
libdar::entrepot_local::clone
virtual entrepot * clone() const override
done this way for homogeneity with open/inherited_open
Definition entrepot_local.hpp:74
libdar::entrepot_local::read_dir_next_dirinfo
virtual bool read_dir_next_dirinfo(std::string &filename, inode_type &tp) const override
alternative to the method read_dir_next, should be implemented also
libdar::entrepot_local::read_dir_flush
virtual void read_dir_flush() const override
ends the read_dir_next, (no more entry available)
Definition entrepot_local.hpp:88
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::etage
the etage structure keep trace of directory contents
Definition etage.hpp:51
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::inode_type
inode_type
type of inode
Definition entrepot_aux.hpp:42
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.