未验证 提交 e75b6921 编写于 作者: 王明冬 提交者: GitHub

fix the opt path create error in windows, test=develop (#33853)

上级 85687348
......@@ -182,15 +182,16 @@ static bool PathExists(const std::string &path) {
}
static std::string GetDirRoot(const std::string &path) {
char sep = '/';
#ifdef _WIN32
sep = '\\';
#endif
size_t i = path.rfind(sep, path.length());
if (i != std::string::npos) {
return (path.substr(0, i));
char sep_1 = '/', sep_2 = '\\';
size_t i_1 = path.rfind(sep_1, path.length());
size_t i_2 = path.rfind(sep_2, path.length());
if (i_1 != std::string::npos && i_2 != std::string::npos) {
return path.substr(0, std::max(i_1, i_2));
} else if (i_1 != std::string::npos) {
return path.substr(0, i_1);
} else if (i_2 != std::string::npos) {
return path.substr(0, i_2);
}
return path;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册