Joedb 9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
SFTP.h
Go to the documentation of this file.
1#ifndef joedb_ssh_SFTP_declared
2#define joedb_ssh_SFTP_declared
3
4#include "joedb/ssh/Session.h"
5
6#include <libssh/sftp.h>
7
8namespace joedb
9{
10 namespace ssh
11 {
12 ///////////////////////////////////////////////////////////////////////////
14 ///////////////////////////////////////////////////////////////////////////
15 {
16 private:
17 static char const * const error_message[];
18
19 protected:
20 const sftp_session sftp;
21
22 public:
23 SFTP_Allocation(const Session &session): sftp(sftp_new(session.get()))
24 {
26 }
27
28 sftp_session get() const
29 {
30 return sftp;
31 }
32
33 void throw_error(const char *message = "sftp error: ") const;
34
35 void check_result(int result) const
36 {
37 if (result != SSH_OK)
39 }
40
42 {
43 sftp_free(sftp);
44 }
45 };
46
47 ///////////////////////////////////////////////////////////////////////////
48 class SFTP: public SFTP_Allocation
49 ////////////////////////////////////////////////////////////////////////////
50 {
51 public:
52 SFTP(const Session &session): SFTP_Allocation(session)
53 {
54 check_result(sftp_init(sftp));
55 }
56 };
57 }
58}
59
60#endif
void check_result(int result) const
Definition SFTP.h:35
sftp_session get() const
Definition SFTP.h:28
SFTP_Allocation(const Session &session)
Definition SFTP.h:23
void throw_error(const char *message="sftp error: ") const
Definition SFTP.cpp:28
const sftp_session sftp
Definition SFTP.h:20
SFTP(const Session &session)
Definition SFTP.h:52
void check_not_null(void *p)
Definition ssh.h:13
Definition Blob.h:7