MCPcopy Create free account
hub / github.com/computationalpathologygroup/ASAP / stripTrailingSlash

Function stripTrailingSlash

core/filetools.cpp:499–531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497//---------------------------------------------------------------------------
498
499 std::string stripTrailingSlash(std::string strPath)
500 {
501#ifdef WIN32
502 char lastchar = strPath[strPath.size()-1];
503 if (lastchar == '\\' || lastchar == '/')
504 {
505 strPath = strPath.substr(0, strPath.size() - 1);
506 }
507 else
508 {
509 std::string x = strPath.substr(strPath.size() - 2, 2);
510 if (x == "\\." || lastchar == '/.')
511 {
512 strPath = strPath.substr(0, strPath.size() - 2);
513 }
514 }
515#else
516 char lastchar = strPath[strPath.size()-1];
517 if (lastchar == '/')
518 {
519 strPath = strPath.substr(0, strPath.size() - 1);
520 }
521 else
522 {
523 std::string x = strPath.substr(strPath.size() - 2, 2);
524 if (x == "/.")
525 {
526 strPath = strPath.substr(0, strPath.size() - 2);
527 }
528 }
529#endif
530 return strPath;
531 }
532
533 std::string completePath(const std::string &spath, const std::string &base)
534 {

Callers 8

upOneLevelFunction · 0.85
upMultipleLevelsFunction · 0.85
extractFilePathFunction · 0.85
extractLowestDirNameFunction · 0.85
completePathFunction · 0.85
changeExtensionFunction · 0.85
changeBaseNameFunction · 0.85
changePathFunction · 0.85

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected