Loading...
Searching...
No Matches
entrepot_local.hpp
Go to the documentation of this file.
/*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2026 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_LOCAL_HPP
#define ENTREPOT_LOCAL_HPP
#include "../my_config.h"
#include <string>
#include "user_interaction.hpp"
#include "entrepot.hpp"
#include "fichier_global.hpp"
#include "etage.hpp"
namespace libdar
{
class entrepot_local : public entrepot
{
public:
entrepot_local(const std::string & user, const std::string & group, bool x_furtive_mode);
entrepot_local(const entrepot_local & ref): entrepot(ref) { copy_from(ref); };
entrepot_local(entrepot_local && ref) noexcept: entrepot(std::move(ref)) { nullifyptr(); move_from(std::move(ref)); };
entrepot_local & operator = (const entrepot_local & ref);
entrepot_local & operator = (entrepot_local && ref) noexcept { entrepot::operator = (std::move(ref)); move_from(std::move(ref)); return *this; };
~entrepot_local() { detruit(); };
virtual std::string get_url() const override { return std::string("file://") + get_full_path().display(); };
virtual void read_dir_reset() const override { read_dir_reset_dirinfo(); };
virtual bool read_dir_next(std::string & filename) const override;
virtual void read_dir_reset_dirinfo() const override;
virtual bool read_dir_next_dirinfo(std::string & filename, inode_type & tp) const override;
virtual void create_dir(const std::string & dirname, U_I permission) override;
virtual entrepot *clone() const override { return new (std::nothrow) entrepot_local(*this); };
protected:
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 override;
virtual void inherited_unlink(const std::string & filename) const override;
virtual void read_dir_flush() const override { detruit(); };
private:
bool furtive_mode;
mutable etage *contents;
void nullifyptr() noexcept { contents = nullptr; };
void copy_from(const entrepot_local & ref) { furtive_mode = ref.furtive_mode; contents = nullptr; };
void move_from(entrepot_local && ref) noexcept { std::swap(contents, ref.contents), std::swap(furtive_mode, ref.furtive_mode); };
void detruit() const { if(contents != nullptr) { delete contents; contents = nullptr; } };
};
} // end of namespace
#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.