forked from abduld/libwb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwbPath.cpp
More file actions
42 lines (38 loc) · 1.21 KB
/
Copy pathwbPath.cpp
File metadata and controls
42 lines (38 loc) · 1.21 KB
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
#include "wb.h"
char *wbPath_join(const char *p1, const char *p2) {
size_t s1 = strlen(p1);
size_t s2 = strlen(p2);
char *res =
wbNewArray(char, s1 + 1 /* seperator */ + s2 + 1 /* terminator */);
memcpy(res, p1, s1);
char *iter = res + s1;
*iter++ = wbDirectorySeperator;
memcpy(iter, p2, s2);
iter += s2;
*iter = '\0';
return res;
}
char *wbPath_join(const char *p1, const char *p2, const char *p3) {
char *p12 = wbPath_join(p1, p2);
char *res = wbPath_join(p12, p3);
wbDelete(p12);
return res;
}
char *wbPath_join(const char *p1, const char *p2, const char *p3,
const char *p4) {
char *p123 = wbPath_join(p1, p2, p3);
char *res = wbPath_join(p123, p4);
wbDelete(p123);
return res;
}
char *wbPath_join(const std::string &p1, const std::string &p2) {
return wbPath_join(p1.c_str(), p2.c_str());
}
char *wbPath_join(const std::string &p1, const std::string &p2,
const std::string &p3) {
return wbPath_join(p1.c_str(), p2.c_str(), p3.c_str());
}
char *wbPath_join(const std::string &p1, const std::string &p2,
const std::string &p3, const std::string &p4) {
return wbPath_join(p1.c_str(), p2.c_str(), p3.c_str(), p4.c_str());
}