----------------------------------------------------------------------------- Purpose: helper to find a directory upstream from a given path -----------------------------------------------------------------------------
| 503 | // Purpose: helper to find a directory upstream from a given path |
| 504 | //----------------------------------------------------------------------------- |
| 505 | std::string Path_FindParentDirectoryRecursively( const std::string &strStartDirectory, const std::string &strDirectoryName ) |
| 506 | { |
| 507 | std::string strFoundPath = ""; |
| 508 | std::string strCurrentPath = Path_FixSlashes( strStartDirectory ); |
| 509 | if ( strCurrentPath.length() == 0 ) |
| 510 | return ""; |
| 511 | |
| 512 | bool bExists = Path_Exists( strCurrentPath ); |
| 513 | std::string strCurrentDirectoryName = Path_StripDirectory( strCurrentPath ); |
| 514 | if ( bExists && stricmp( strCurrentDirectoryName.c_str(), strDirectoryName.c_str() ) == 0 ) |
| 515 | return strCurrentPath; |
| 516 | |
| 517 | while( bExists && strCurrentPath.length() != 0 ) |
| 518 | { |
| 519 | strCurrentPath = Path_StripFilename( strCurrentPath ); |
| 520 | strCurrentDirectoryName = Path_StripDirectory( strCurrentPath ); |
| 521 | bExists = Path_Exists( strCurrentPath ); |
| 522 | if ( bExists && stricmp( strCurrentDirectoryName.c_str(), strDirectoryName.c_str() ) == 0 ) |
| 523 | return strCurrentPath; |
| 524 | } |
| 525 | |
| 526 | return ""; |
| 527 | } |
| 528 | |
| 529 | |
| 530 | //----------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected