Returns true if pathname describes a directory in the file-system that exists.
| 7641 | // Returns true if pathname describes a directory in the file-system |
| 7642 | // that exists. |
| 7643 | bool FilePath::DirectoryExists() const { |
| 7644 | bool result = false; |
| 7645 | #if GTEST_OS_WINDOWS |
| 7646 | // Don't strip off trailing separator if path is a root directory on |
| 7647 | // Windows (like "C:\\"). |
| 7648 | const FilePath& path(IsRootDirectory() ? *this : |
| 7649 | RemoveTrailingPathSeparator()); |
| 7650 | #else |
| 7651 | const FilePath& path(*this); |
| 7652 | #endif |
| 7653 | |
| 7654 | #if GTEST_OS_WINDOWS_MOBILE |
| 7655 | LPCWSTR unicode = String::AnsiToUtf16(path.c_str()); |
| 7656 | const DWORD attributes = GetFileAttributes(unicode); |
| 7657 | delete [] unicode; |
| 7658 | if ((attributes != kInvalidFileAttributes) && |
| 7659 | (attributes & FILE_ATTRIBUTE_DIRECTORY)) { |
| 7660 | result = true; |
| 7661 | } |
| 7662 | #else |
| 7663 | posix::StatStruct file_stat; |
| 7664 | result = posix::Stat(path.c_str(), &file_stat) == 0 && |
| 7665 | posix::IsDir(file_stat); |
| 7666 | #endif // GTEST_OS_WINDOWS_MOBILE |
| 7667 | |
| 7668 | return result; |
| 7669 | } |
| 7670 | |
| 7671 | // Returns true if pathname describes a root directory. (Windows has one |
| 7672 | // root directory per disk drive.) |
no test coverage detected