| 285 | ////////////////////////////////////////////////////////////////////////// |
| 286 | |
| 287 | std::string getGenericPath(const std::string& _path) |
| 288 | { |
| 289 | std::string path = _path; |
| 290 | size_t offset = std::string::npos; |
| 291 | |
| 292 | // remove "\\\\?\\" |
| 293 | if((path.find("\\\\?\\")) == 0) |
| 294 | path.erase(0, 4); |
| 295 | |
| 296 | // convert '\\' to '/' |
| 297 | while((offset = path.find('\\')) != std::string::npos) |
| 298 | path.replace(offset, 1 ,"/"); |
| 299 | |
| 300 | // remove double '/' |
| 301 | while((offset = path.find("//")) != std::string::npos) |
| 302 | path.erase(offset, 1); |
| 303 | |
| 304 | // remove trailing '/' when the path is more than a simple '/' |
| 305 | while(path.length() > 1 && ((offset = path.find_last_of('/')) == (path.length() - 1))) |
| 306 | path.erase(offset, 1); |
| 307 | |
| 308 | // return generic path |
| 309 | return path; |
| 310 | |
| 311 | } // getGenericPath |
| 312 | |
| 313 | ////////////////////////////////////////////////////////////////////////// |
| 314 |
no test coverage detected