Loading...
Searching...
No Matches
entrepot_libssh.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_LIBSSH_HPP
#define ENTREPOT_LIBSSH_HPP
#include "../my_config.h"
extern "C"
{
#if HAVE_LIBSSH_LIBSSH_H
#include <libssh/libssh.h>
#include <libssh/sftp.h>
#endif
}
#include <string>
#include <memory>
#include "mem_ui.hpp"
#include "entrepot.hpp"
#include "fichier_global.hpp"
#include "libssh_connection.hpp"
namespace libdar
{
class entrepot_libssh : public entrepot, public mem_ui
{
public:
entrepot_libssh(const std::shared_ptr<user_interaction> & dialog,
const std::string & login,
const secu_string & password,
const std::string & host,
const std::string & port,
bool auth_from_file,
const std::string & sftp_pub_keyfile,
const std::string & sftp_prv_keyfile,
const std::string & sftp_known_hosts,
U_I waiting_time,
bool verbose = false
);
entrepot_libssh(const entrepot_libssh & ref);
entrepot_libssh(entrepot_libssh && ref) noexcept = delete;
entrepot_libssh & operator = (const entrepot_libssh & ref) = delete;
entrepot_libssh & operator = (entrepot_libssh && ref) noexcept = delete;
~entrepot_libssh() noexcept { read_dir_flush(); };
virtual std::string get_url() const override;
virtual void read_dir_reset() const override;
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_libssh(*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;
private:
#if LIBSSH_AVAILABLE
// constructor received parameters
std::string server_url;
// libssh structures
mutable sftp_dir sdir; // using for read_dir/read_next[_dirinfo]() paradygm
// shared libssh structures
std::shared_ptr<libssh_connection> connect;
#endif
};
} // end of namespace
#endif
libdar::entrepot_libssh::read_dir_flush
virtual void read_dir_flush() const override
ends the read_dir_next, (no more entry available)
libdar::entrepot_libssh::clone
virtual entrepot * clone() const override
done this way for homogeneity with open/inherited_open
Definition entrepot_libssh.hpp:91
libdar::entrepot_libssh::create_dir
virtual void create_dir(const std::string &dirname, U_I permission) override
create a new directory in the current directory
libdar::entrepot_libssh::read_dir_next
virtual bool read_dir_next(std::string &filename) const override
read the next filename of the current directory
libdar::entrepot_libssh::read_dir_reset_dirinfo
virtual void read_dir_reset_dirinfo() const override
routines to read existing files with dir information
libdar::entrepot_libssh::entrepot_libssh
entrepot_libssh(const std::shared_ptr< user_interaction > &dialog, const std::string &login, const secu_string &password, const std::string &host, const std::string &port, bool auth_from_file, const std::string &sftp_pub_keyfile, const std::string &sftp_prv_keyfile, const std::string &sftp_known_hosts, U_I waiting_time, bool verbose=false)
constructor
libdar::entrepot_libssh::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_libssh::read_dir_reset
virtual void read_dir_reset() const override
routines to read existing files in the current directory (see set_location() / set_root() methods)
libdar::entrepot_libssh::get_url
virtual std::string get_url() const override
full path of current directory + anything necessary to provide URL formated information
libdar::entrepot::entrepot
entrepot()
constructor
libdar::fichier_global
abstraction of filesystem files for entrepot
Definition fichier_global.hpp:59
libdar::mem_ui::mem_ui
mem_ui(const std::shared_ptr< user_interaction > &dialog)
constructor
libdar::secu_string
class secu_string
Definition secu_string.hpp:54
entrepot.hpp
defines the entrepot interface.
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
libssh_connection.hpp
class holding libssh related data structure for an ssh and sftp session
mem_ui.hpp
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
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