Disk ARchive: entrepot.hpp Source File

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

Loading...
Searching...
No Matches
entrepot.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
32
33#ifndef ENTREPOT_HPP
34#define ENTREPOT_HPP
35
36#include "../my_config.h"
37
38#include <string>
39#include <memory>
40#include "user_interaction.hpp"
41#include "path.hpp"
42#include "archive_aux.hpp"
43#include "gf_mode.hpp"
44#include "entrepot_aux.hpp"
45
46namespace libdar
47{
50
51 // no need to dig into this from API header
52 class fichier_global;
53
55
56 class entrepot
57 {
58 public:
59
61 entrepot();
62
64 entrepot(const entrepot & ref) = default;
65
67 entrepot(entrepot && ref) noexcept = default;
68
70 entrepot & operator = (const entrepot & ref) = default;
71
73 entrepot & operator = (entrepot && ref) noexcept = default;
74
76 virtual ~entrepot() = default;
77
79 bool operator == (const entrepot & ref) const { return get_url() == ref.get_url(); };
80
81
83 virtual void set_location(const path & chemin);
84
86 virtual void set_root(const path & p_root);
87
89
91 virtual path get_full_path() const;
92
94 virtual std::string get_url() const = 0;
95
97 void set_user_ownership(const std::string & x_user) { user = x_user; };
98 void set_group_ownership(const std::string & x_group) { group = x_group; };
99
100 virtual const path & get_location() const { return where; };
101 virtual const path & get_root() const { return root; };
102
103 const std::string & get_user_ownership() const { return user; };
104 const std::string & get_group_ownership() const { return group; };
105
107
119 fichier_global *open(const std::shared_ptr<user_interaction> & dialog,
120 const std::string & filename,
121 gf_mode mode,
122 bool force_permission,
123 U_I permission,
124 bool fail_if_exists,
125 bool erase,
126 hash_algo algo,
127 bool provide_a_plain_file = true) const;
128
130
132 virtual void change_user_interaction(const std::shared_ptr<user_interaction> & new_dialog) {};
133
135 virtual std::shared_ptr<user_interaction> get_current_user_interaction() const { return std::shared_ptr<user_interaction>(); };
136
138
142 virtual void read_dir_reset() const = 0;
143
145
150 virtual bool read_dir_next(std::string & filename) const = 0;
151
152
154
158 virtual void read_dir_reset_dirinfo() const = 0;
159
160
162
168 virtual bool read_dir_next_dirinfo(std::string & filename, inode_type & tp) const = 0;
169
171
178 virtual void create_dir(const std::string & dirname, U_I permission) = 0;
179
181 void unlink(const std::string & filename) const { inherited_unlink(filename); };
182
184
187 virtual entrepot *clone() const = 0;
188
189 protected:
190 virtual fichier_global *inherited_open(const std::shared_ptr<user_interaction> & dialog,
191 const std::string & filename,
192 gf_mode mode,
193 bool force_permission,
194 U_I permission,
195 bool fail_if_exists,
196 bool erase
197 ) const = 0;
198
199 virtual void inherited_unlink(const std::string & filename) const = 0;
200
201 virtual void read_dir_flush() const = 0;
202
203 private:
204 path where;
205 path root;
206 std::string user;
207 std::string group;
208 };
209
211
212} // end of namespace
213
214#endif
archive_aux.hpp
set of datastructures used to interact with a catalogue object
libdar::entrepot::open
fichier_global * open(const std::shared_ptr< 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, bool provide_a_plain_file=true) const
defines the way to open a file and return a "class fichier_global" object as last argument upon succe...
libdar::entrepot::change_user_interaction
virtual void change_user_interaction(const std::shared_ptr< user_interaction > &new_dialog)
change user_interaction if the implementation recorded it (at construction time for example)
Definition entrepot.hpp:132
libdar::entrepot::get_full_path
virtual path get_full_path() const
returns the full path of location
libdar::entrepot::read_dir_flush
virtual void read_dir_flush() const =0
ends the read_dir_next, (no more entry available)
libdar::entrepot::read_dir_reset
virtual void read_dir_reset() const =0
routines to read existing files in the current directory (see set_location() / set_root() methods)
libdar::entrepot::entrepot
entrepot(entrepot &&ref) noexcept=default
move constructor
libdar::entrepot::entrepot
entrepot()
constructor
libdar::entrepot::entrepot
entrepot(const entrepot &ref)=default
copy constructor
libdar::entrepot::set_location
virtual void set_location(const path &chemin)
defines the directory where to proceed to future open() – this is a "chdir" semantics
libdar::entrepot::operator==
bool operator==(const entrepot &ref) const
says whether two entrepot objects points to the same location
Definition entrepot.hpp:79
libdar::entrepot::create_dir
virtual void create_dir(const std::string &dirname, U_I permission)=0
create a new directory in the current directory
libdar::entrepot::inherited_open
virtual fichier_global * inherited_open(const std::shared_ptr< user_interaction > &dialog, const std::string &filename, gf_mode mode, bool force_permission, U_I permission, bool fail_if_exists, bool erase) const =0
libdar::entrepot::set_user_ownership
void set_user_ownership(const std::string &x_user)
set default ownership for files to be created thanks to the open() or create_dir() methods
Definition entrepot.hpp:97
libdar::entrepot::~entrepot
virtual ~entrepot()=default
destructor
libdar::entrepot::operator=
entrepot & operator=(const entrepot &ref)=default
assignment operator
libdar::entrepot::get_url
virtual std::string get_url() const =0
full path of current directory + anything necessary to provide URL formated information
libdar::entrepot::set_root
virtual void set_root(const path &p_root)
defines the root to use if set_location is given a relative path
libdar::entrepot::get_root
virtual const path & get_root() const
retreives relative to root path the current location points to
Definition entrepot.hpp:101
libdar::entrepot::read_dir_reset_dirinfo
virtual void read_dir_reset_dirinfo() const =0
routines to read existing files with dir information
libdar::entrepot::read_dir_next_dirinfo
virtual bool read_dir_next_dirinfo(std::string &filename, inode_type &tp) const =0
alternative to the method read_dir_next, should be implemented also
libdar::entrepot::get_current_user_interaction
virtual std::shared_ptr< user_interaction > get_current_user_interaction() const
get the current user_interaction if the implementation reocrded it at construction time (may be nullp...
Definition entrepot.hpp:135
libdar::entrepot::get_user_ownership
const std::string & get_user_ownership() const
retrieves the given root location
Definition entrepot.hpp:103
libdar::entrepot::read_dir_next
virtual bool read_dir_next(std::string &filename) const =0
read the next filename of the current directory
libdar::entrepot::unlink
void unlink(const std::string &filename) const
remove the target file from the entrepot
Definition entrepot.hpp:181
libdar::entrepot::clone
virtual entrepot * clone() const =0
done this way for homogeneity with open/inherited_open
libdar::fichier_global
abstraction of filesystem files for entrepot
Definition fichier_global.hpp:59
libdar::path
the class path is here to manipulate paths in the Unix notation: using'/'
Definition path.hpp:51
entrepot_aux.hpp
set of datastructures used to interact with entrepot objects
gf_mode.hpp
generic modes to open file
libdar::hash_algo
hash_algo
hashing algorithm available
Definition archive_aux.hpp:63
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
path.hpp
here is the definition of the path class
user_interaction.hpp
defines the interaction interface between libdar and users.