Disk ARchive 2.8.3
Full featured and portable backup and archiving tool
Loading...
Searching...
No Matches
entrepot_libssh.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_LIBSSH_HPP
28#define ENTREPOT_LIBSSH_HPP
29
30#include "../my_config.h"
31
32extern "C"
33{
34#if HAVE_LIBSSH_LIBSSH_H
35#include <libssh/libssh.h>
36#include <libssh/sftp.h>
37#endif
38}
39
40#include <string>
41#include <memory>
42
43#include "mem_ui.hpp"
44#include "entrepot.hpp"
45#include "fichier_global.hpp"
46#include "libssh_connection.hpp"
47
48namespace libdar
49{
52
56
57 class entrepot_libssh : public entrepot, public mem_ui
58 {
59 public:
60
62
63 entrepot_libssh(const std::shared_ptr<user_interaction> & dialog,
64 const std::string & login,
65 const secu_string & password,
66 const std::string & host,
67 const std::string & port,
68 bool auth_from_file,
69 const std::string & sftp_pub_keyfile,
70 const std::string & sftp_prv_keyfile,
71 const std::string & sftp_known_hosts,
72 U_I waiting_time,
73 bool verbose = false
74 );
75
77 entrepot_libssh(entrepot_libssh && ref) noexcept = delete;
78 entrepot_libssh & operator = (const entrepot_libssh & ref) = delete;
79 entrepot_libssh & operator = (entrepot_libssh && ref) noexcept = delete;
80 ~entrepot_libssh() noexcept { read_dir_flush(); };
81
82 virtual std::string get_url() const override;
83
84 virtual void read_dir_reset() const override;
85 virtual bool read_dir_next(std::string & filename) const override;
86 virtual void read_dir_reset_dirinfo() const override;
87 virtual bool read_dir_next_dirinfo(std::string & filename, inode_type & tp) const override;
88
89 virtual void create_dir(const std::string & dirname, U_I permission) override;
90
91 virtual entrepot *clone() const override { return new (std::nothrow) entrepot_libssh(*this); };
92
93
94 protected:
95 virtual fichier_global *inherited_open(const std::shared_ptr<user_interaction> & dialog,
96 const std::string & filename,
97 gf_mode mode,
98 bool force_permission,
99 U_I permission,
100 bool fail_if_exists,
101 bool erase) const override;
102
103 virtual void inherited_unlink(const std::string & filename) const override;
104 virtual void read_dir_flush() const override;
105
106 private:
107#if LIBSSH_AVAILABLE
108 // constructor received parameters
109 std::string server_url;
110
111 // libssh structures
112 mutable sftp_dir sdir; // using for read_dir/read_next[_dirinfo]() paradygm
113
114 // shared libssh structures
115 std::shared_ptr<libssh_connection> connect;
116#endif
117
118 };
119
121
122} // end of namespace
123
124#endif
virtual void read_dir_flush() const override
ends the read_dir_next, (no more entry available)
virtual entrepot * clone() const override
done this way for homogeneity with open/inherited_open
virtual void create_dir(const std::string &dirname, U_I permission) override
create a new directory in the current directory
virtual bool read_dir_next(std::string &filename) const override
read the next filename of the current directory
virtual void read_dir_reset_dirinfo() const override
routines to read existing files with dir information
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
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
virtual void read_dir_reset() const override
routines to read existing files in the current directory (see set_location() / set_root() methods)
virtual std::string get_url() const override
full path of current directory + anything necessary to provide URL formated information
entrepot()
constructor
abstraction of filesystem files for entrepot
mem_ui(const std::shared_ptr< user_interaction > &dialog)
constructor
gf_mode
generic_file openning modes
class holding libssh related data structure for an ssh and sftp session
include macro defined by the configure script and some specific additional ones
libdar namespace encapsulate all libdar symbols
defines the entrepot interface.
class fichier_global definition. This class is a pure virtual class class fichier_global is an abstra...
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...