MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / Path_FindParentSubDirectoryRecursively

Function Path_FindParentSubDirectoryRecursively

samples/shared/pathtools.cpp:533–553  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Purpose: helper to find a subdirectory upstream from a given path -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

531// Purpose: helper to find a subdirectory upstream from a given path
532//-----------------------------------------------------------------------------
533std::string Path_FindParentSubDirectoryRecursively( const std::string &strStartDirectory, const std::string &strDirectoryName )
534{
535 std::string strFoundPath = "";
536 std::string strCurrentPath = Path_FixSlashes( strStartDirectory );
537 if ( strCurrentPath.length() == 0 )
538 return "";
539
540 bool bExists = Path_Exists( strCurrentPath );
541 while( bExists && strCurrentPath.length() != 0 )
542 {
543 strCurrentPath = Path_StripFilename( strCurrentPath );
544 bExists = Path_Exists( strCurrentPath );
545
546 if( Path_Exists( Path_Join( strCurrentPath, strDirectoryName ) ) )
547 {
548 strFoundPath = Path_Join( strCurrentPath, strDirectoryName );
549 break;
550 }
551 }
552 return strFoundPath;
553}
554
555
556//-----------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 5

Path_FixSlashesFunction · 0.70
Path_ExistsFunction · 0.70
Path_StripFilenameFunction · 0.70
Path_JoinFunction · 0.70
lengthMethod · 0.45

Tested by

no test coverage detected