Loading...
Searching...
No Matches
entrepot.hpp
Go to the documentation of this file.
/*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2024 Denis Corbin
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// to contact the author, see the AUTHOR file
/*********************************************************************/
#ifndef ENTREPOT_HPP
#define ENTREPOT_HPP
#include "../my_config.h"
#include <string>
#include <memory>
#include "user_interaction.hpp"
#include "path.hpp"
#include "archive_aux.hpp"
#include "gf_mode.hpp"
namespace libdar
{
// no need to dig into this from API header
class fichier_global;
class entrepot
{
public:
entrepot();
entrepot(const entrepot & ref) = default;
entrepot(entrepot && ref) noexcept = default;
entrepot & operator = (const entrepot & ref) = default;
entrepot & operator = (entrepot && ref) noexcept = default;
virtual ~entrepot() = default;
bool operator == (const entrepot & ref) const { return get_url() == ref.get_url(); };
virtual void set_location(const path & chemin);
virtual void set_root(const path & p_root);
virtual path get_full_path() const;
virtual std::string get_url() const = 0;
void set_user_ownership(const std::string & x_user) { user = x_user; };
void set_group_ownership(const std::string & x_group) { group = x_group; };
virtual const path & get_location() const { return where; }; //< retreives relative to root path the current location points to
virtual const path & get_root() const { return root; }; //< retrieves the given root location
const std::string & get_user_ownership() const { return user; };
const std::string & get_group_ownership() const { return group; };
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;
virtual void read_dir_reset() const = 0;
virtual bool read_dir_next(std::string & filename) const = 0;
void unlink(const std::string & filename) const { inherited_unlink(filename); }; //< done this way for homogeneity with open/inherited_open
virtual entrepot *clone() const = 0;
protected:
virtual fichier_global *inherited_open(const std::shared_ptr<user_interaction> & dialog, //< for user interaction
const std::string & filename, //< filename to open
gf_mode mode, //< mode to use
bool force_permission, //< set the permission of the file to open
U_I permission, //< value of the permission to assign when force_permission is true
bool fail_if_exists, //< whether to fail if file exists (write mode)
bool erase) const = 0; //< whether to erase file if file already exists (write mode)
virtual void inherited_unlink(const std::string & filename) const = 0;
virtual void read_dir_flush() = 0; //< ends the read_dir_next, (no more entry available)
private:
path where;
path root;
std::string user;
std::string group;
};
} // end of namespace
#endif
archive_aux.hpp
set of datastructures used to interact with a catalogue object
libdar::entrepot
the Entrepot interface
Definition entrepot.hpp:56
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::get_full_path
virtual path get_full_path() const
returns the full path of location
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:78
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() methods
Definition entrepot.hpp:96
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::clone
virtual entrepot * clone() const =0
generate a clone of "this"
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
gf_mode.hpp
generic modes to open file
libdar::hash_algo
hash_algo
hashing algorithm available
Definition archive_aux.hpp:63
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.