realPath
This commit is contained in:
parent
630ca77b98
commit
f1c5641ed0
|
@ -36,4 +36,6 @@ bool readFile(int fd, std::ostream& output, unsigned int maxsize = 0);
|
|||
bool copy(int fd_from, int fd_to);
|
||||
bool copy(const std::string& from, const std::string& to);
|
||||
|
||||
std::string realPath(const std::string& str);
|
||||
|
||||
}
|
|
@ -145,3 +145,11 @@ bool mrbesen::files::copy(const std::string& from, const std::string& to) {
|
|||
|
||||
return r;
|
||||
}
|
||||
|
||||
std::string mrbesen::files::realPath(const std::string& str) {
|
||||
char buffer[PATH_MAX];
|
||||
char* ret = ::realpath(str.c_str(), buffer);
|
||||
if(ret == nullptr) return "";
|
||||
|
||||
return std::string(buffer);
|
||||
}
|
|
@ -23,6 +23,7 @@ int testUtil_equalsIgnoreCase() {
|
|||
std::string a = "abcdefg";
|
||||
std::string b = "AbCdEHI";
|
||||
std::string c = "AbCdEHIJ";
|
||||
std::string d = "aBcDeFg";
|
||||
|
||||
ASSERT(!equalsIgnoreCase(a, b), "");
|
||||
ASSERT(!equalsIgnoreCase(a, b, 10000), "");
|
||||
|
@ -36,6 +37,8 @@ int testUtil_equalsIgnoreCase() {
|
|||
ASSERT(!equalsIgnoreCase(a, c, 8), "");
|
||||
ASSERT(equalsIgnoreCase(a, c, 5), "");
|
||||
|
||||
ASSERT(equalsIgnoreCase(a, d), "");
|
||||
|
||||
return TESTGOOD;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue