Merge 2c4147e2e954d500e1b772474f294342907fb4f7 into 7140cd416cecd7462a8aae488024abeee55598e4

This commit is contained in:
Sergei 2026-06-11 19:28:20 +02:00 committed by GitHub
commit 6d8fa41cf5
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));