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