Merge 2c4147e2e954d500e1b772474f294342907fb4f7 into 1b96fa13f549387b7549cc89e1a785cf143a1a50

This commit is contained in:
Sergey 2025-11-14 12:14:41 +08:00 committed by GitHub
commit 0b941e4afa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -109,7 +109,10 @@ FilePath FilePath::GetCurrentDir() {
return FilePath(kCurrentDirectoryString);
#elif defined(GTEST_OS_WINDOWS)
char cwd[GTEST_PATH_MAX_ + 1] = {'\0'};
return FilePath(_getcwd(cwd, sizeof(cwd)) == nullptr ? "" : cwd);
if (_getcwd(cwd, sizeof(cwd)) == nullptr) return {};
auto len = std::strlen(cwd);
if (len > 0 && cwd[len - 1] == '\\') cwd[--len] = 0;
return FilePath({cwd, len});
#else
char cwd[GTEST_PATH_MAX_ + 1] = {'\0'};
char* result = getcwd(cwd, sizeof(cwd));