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

Function Path_IsDirectory

samples/shared/pathtools.cpp:425–459  ·  view source on GitHub ↗

returns true if the specified path exists and is a directory */

Source from the content-addressed store, hash-verified

423
424/** returns true if the specified path exists and is a directory */
425bool Path_IsDirectory( const std::string & sPath )
426{
427 std::string sFixedPath = Path_FixSlashes( sPath );
428 if( sFixedPath.empty() )
429 return false;
430 char cLast = sFixedPath[ sFixedPath.length() - 1 ];
431 if( cLast == '/' || cLast == '\\' )
432 sFixedPath.erase( sFixedPath.end() - 1, sFixedPath.end() );
433
434 // see if the specified path actually exists.
435
436#if defined(POSIX)
437 struct stat buf;
438 if ( stat( sFixedPath.c_str(), &buf ) == -1 )
439 {
440 return false;
441 }
442
443#if defined( LINUX ) || defined( OSX )
444 return S_ISDIR( buf.st_mode );
445#else
446 return (buf.st_mode & _S_IFDIR) != 0;
447#endif
448
449#else
450 struct _stat buf;
451 std::wstring wsFixedPath = UTF8to16( sFixedPath.c_str() );
452 if ( _wstat( wsFixedPath.c_str(), &buf ) == -1 )
453 {
454 return false;
455 }
456
457 return (buf.st_mode & _S_IFDIR) != 0;
458#endif
459}
460
461/** returns true if the specified path represents an app bundle */
462bool Path_IsAppBundle( const std::string & sPath )

Callers

nothing calls this directly

Calls 6

emptyMethod · 0.80
endMethod · 0.80
Path_FixSlashesFunction · 0.70
statClass · 0.70
UTF8to16Function · 0.70
lengthMethod · 0.45

Tested by

no test coverage detected