diff options
author | shiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925> | 2008-09-12 04:01:37 (GMT) |
---|---|---|
committer | shiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925> | 2008-09-12 04:01:37 (GMT) |
commit | 019d19af978f05b774407e0d46a3bda2c18c67c6 (patch) | |
tree | 8522f2db6e168ee4e829c2e7f2cf6dfbaaab30c7 /src/gtest-filepath.cc | |
parent | 29d8235540f1983c3dbd53a23783530017be80e7 (diff) | |
download | googletest-019d19af978f05b774407e0d46a3bda2c18c67c6.zip googletest-019d19af978f05b774407e0d46a3bda2c18c67c6.tar.gz googletest-019d19af978f05b774407e0d46a3bda2c18c67c6.tar.bz2 |
Improves thread-safe death tests by changing to the original working directory before they are executed; also fixes out-dated comments about death tests.
Diffstat (limited to 'src/gtest-filepath.cc')
-rw-r--r-- | src/gtest-filepath.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gtest-filepath.cc b/src/gtest-filepath.cc index 3c32c70..2a5be8c 100644 --- a/src/gtest-filepath.cc +++ b/src/gtest-filepath.cc @@ -32,6 +32,8 @@ #include <gtest/internal/gtest-filepath.h> #include <gtest/internal/gtest-port.h> +#include <stdlib.h> + #ifdef _WIN32_WCE #include <windows.h> #elif defined(_WIN32) @@ -40,6 +42,7 @@ #include <sys/stat.h> #else #include <sys/stat.h> +#include <unistd.h> #endif // _WIN32_WCE or _WIN32 #include <gtest/internal/gtest-string.h> @@ -66,6 +69,21 @@ const char kPathSeparatorString[] = "/"; const char kCurrentDirectoryString[] = "./"; #endif // GTEST_OS_WINDOWS +// Returns the current working directory, or "" if unsuccessful. +FilePath FilePath::GetCurrentDir() { +#ifdef _WIN32_WCE +// Windows CE doesn't have a current directory, so we just return +// something reasonable. + return FilePath(kCurrentDirectoryString); +#elif defined(GTEST_OS_WINDOWS) + char cwd[_MAX_PATH + 1] = {}; + return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd); +#else + char cwd[PATH_MAX + 1] = {}; + return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd); +#endif +} + // Returns a copy of the FilePath with the case-insensitive extension removed. // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns // FilePath("dir/file"). If a case-insensitive extension is not |