--------------------------------- FileUtil::SplitFirstDirectory Returns the first directory component, if any. The path variable will be modified to contain what is left
| 362 | // Returns the first directory component, if any. The path variable will be modified to contain what is left |
| 363 | // |
| 364 | std::string FileUtil::SplitFirstDirectory(std::string& path) |
| 365 | { |
| 366 | // get the first delimiter |
| 367 | size_t closestIdx = std::numeric_limits<size_t>::max(); |
| 368 | for (char const token : pathDelimiters) |
| 369 | { |
| 370 | size_t index = path.find(token); |
| 371 | if (index != std::string::npos && index < closestIdx) |
| 372 | { |
| 373 | closestIdx = index; |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | // if none is found return an empty path |
| 378 | if (closestIdx > path.size()) |
| 379 | { |
| 380 | return ""; |
| 381 | } |
| 382 | |
| 383 | ++closestIdx; |
| 384 | |
| 385 | std::string ret = path.substr(0, closestIdx); |
| 386 | path = path.substr(closestIdx); |
| 387 | return ret; |
| 388 | } |
| 389 | |
| 390 | //--------------------------------- |
| 391 | // FileUtil::GetAbsolutePath |
nothing calls this directly
no outgoing calls
no test coverage detected