File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
paddle/fluid/inference/analysis Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -182,15 +182,16 @@ static bool PathExists(const std::string &path) {
182182}
183183
184184static std::string GetDirRoot (const std::string &path) {
185- char sep = ' /' ;
186-
187- #ifdef _WIN32
188- sep = ' \\ ' ;
189- #endif
190-
191- size_t i = path.rfind (sep, path.length ());
192- if (i != std::string::npos) {
193- return (path.substr (0 , i));
185+ char sep_1 = ' /' , sep_2 = ' \\ ' ;
186+
187+ size_t i_1 = path.rfind (sep_1, path.length ());
188+ size_t i_2 = path.rfind (sep_2, path.length ());
189+ if (i_1 != std::string::npos && i_2 != std::string::npos) {
190+ return path.substr (0 , std::max (i_1, i_2));
191+ } else if (i_1 != std::string::npos) {
192+ return path.substr (0 , i_1);
193+ } else if (i_2 != std::string::npos) {
194+ return path.substr (0 , i_2);
194195 }
195196 return path;
196197}
You can’t perform that action at this time.
0 commit comments