-
Notifications
You must be signed in to change notification settings - Fork 3
/
WebdavClient.h
61 lines (48 loc) · 1.53 KB
/
WebdavClient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef WebdavClient_H
#define WebdavClient_H
#include <string>
#include <vector>
#include <neon/ne_props.h> /* ne_prop_result_set, ne_session */
struct WebdavPath {
WebdavPath(std::string host, std::string path, std::string ressourceType, std::string lastModified, std::string contentType) :
host(host),
path(path),
ressourceType(ressourceType),
lastModified(lastModified),
contentType(contentType) {
}
bool isFile(){
if(!ressourceType.compare(""))
return true;
return false;
}
bool isDirectory(){
return !isFile();
}
std::string host;
std::string path;
std::string ressourceType;
std::string lastModified;
std::string contentType;
};
class WebdavClient {
public:
WebdavClient(const std::string url, const unsigned port, const std::string user, const std::string pass);
~WebdavClient();
std::vector<WebdavPath> ls(std::string uri);
std::vector<WebdavPath> tree(std::string uri);
std::string getLastError();
bool exist(std::string uri);
bool put(std::string uri, std::string localSource);
bool get(std::string uri, std::string localDestination);
bool mkdir(std::string uri);
bool rm(std::string uri);
bool mv(std::string uriFrom, std::string uriTo);
private:
static int setLogin(void *userdata, const char *realm, int attempts, char *usernmae, char *password);
static void getProps(void *userdata, const ne_uri *uri, const ne_prop_result_set *set);
ne_session *mSession;
std::string mError;
std::vector<std::string> login_info;
};
#endif /* WebdavClient_H */