Skip to content

Commit

Permalink
fix the opt path create error in windows, test=develop (#33853) (#33885)
Browse files Browse the repository at this point in the history
  • Loading branch information
winter-wang committed Jul 1, 2021
1 parent 3749af5 commit 702610e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions paddle/fluid/inference/analysis/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 702610e

Please sign in to comment.