returns true if the specified path exists and is a directory */
| 423 | |
| 424 | /** returns true if the specified path exists and is a directory */ |
| 425 | bool 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 */ |
| 462 | bool Path_IsAppBundle( const std::string & sPath ) |