Create the directory so that path exists. Returns true if successful or if the directory already exists; returns false if unable to create the directory for any reason, including if the parent directory does not exist. Not named "CreateDirectory" because that's a macro on Windows.
| 8152 | // directory for any reason, including if the parent directory does not |
| 8153 | // exist. Not named "CreateDirectory" because that's a macro on Windows. |
| 8154 | bool FilePath::CreateFolder() const { |
| 8155 | #if GTEST_OS_WINDOWS_MOBILE |
| 8156 | FilePath removed_sep(this->RemoveTrailingPathSeparator()); |
| 8157 | LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str()); |
| 8158 | int result = CreateDirectory(unicode, NULL) ? 0 : -1; |
| 8159 | delete [] unicode; |
| 8160 | #elif GTEST_OS_WINDOWS |
| 8161 | int result = _mkdir(pathname_.c_str()); |
| 8162 | #else |
| 8163 | int result = mkdir(pathname_.c_str(), 0777); |
| 8164 | #endif // GTEST_OS_WINDOWS_MOBILE |
| 8165 | |
| 8166 | if (result == -1) { |
| 8167 | return this->DirectoryExists(); // An error is OK if the directory exists. |
| 8168 | } |
| 8169 | return true; // No error. |
| 8170 | } |
| 8171 | |
| 8172 | // If input name has a trailing separator character, remove it and return the |
| 8173 | // name, otherwise return the name string unmodified. |
no test coverage detected