From 4650552ff637bb44ecf7784060091cbed3252211 Mon Sep 17 00:00:00 2001 From: "kosak@google.com" Date: Tue, 29 Jul 2014 00:30:10 +0000 Subject: Mock out GetCurrentDir in NaCl. git-svn-id: http://googletest.googlecode.com/svn/trunk@692 861a406c-534a-0410-8894-cb66d6ee9925 --- src/gtest-filepath.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gtest-filepath.cc b/src/gtest-filepath.cc index 219875c..0292dc1 100644 --- a/src/gtest-filepath.cc +++ b/src/gtest-filepath.cc @@ -106,7 +106,14 @@ FilePath FilePath::GetCurrentDir() { return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd); #else char cwd[GTEST_PATH_MAX_ + 1] = { '\0' }; - return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd); + char* result = getcwd(cwd, sizeof(cwd)); +# if GTEST_OS_NACL + // getcwd will likely fail in NaCl due to the sandbox, so return something + // reasonable. The user may have provided a shim implementation for getcwd, + // however, so fallback only when failure is detected. + return FilePath(result == NULL ? kCurrentDirectoryString : cwd); +# endif // GTEST_OS_NACL + return FilePath(result == NULL ? "" : cwd); #endif // GTEST_OS_WINDOWS_MOBILE } -- cgit v1.2.3