windows....sigh
This commit is contained in:
29
rktwebview_qt/utils.h
Normal file
29
rktwebview_qt/utils.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
inline std::string basedir(const std::string &path)
|
||||
{
|
||||
int idx1 = path.rfind("/");
|
||||
int idx2 = path.rfind("\\");
|
||||
std::string r;
|
||||
if (idx1 == std::string::npos && idx2 == std::string::npos) {
|
||||
r = "";
|
||||
} else {
|
||||
int idx;
|
||||
if (idx1 == std::string::npos) {
|
||||
idx = idx2;
|
||||
} else if (idx2 == std::string::npos) {
|
||||
idx = idx1;
|
||||
} else if (idx1 < idx2) {
|
||||
idx = idx2;
|
||||
} else {
|
||||
idx = idx1;
|
||||
}
|
||||
r = path.substr(0, idx);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif // UTILS_H
|
||||
Reference in New Issue
Block a user