338338#define GTEST_HAS_NOTIFICATION_ 0
339339#endif
340340
341- #ifdef GTEST_HAS_ABSL
342- #include " absl/flags/declare.h "
341+ #if defined( GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
342+ #define GTEST_INTERNAL_HAS_ABSL_FLAGS // Used only in this file.
343343#include " absl/flags/flag.h"
344+ #include " absl/flags/declare.h"
344345#include " absl/flags/reflection.h"
345346#endif
346347
@@ -2005,7 +2006,9 @@ inline std::string StripTrailingSpaces(std::string str) {
20052006namespace posix {
20062007
20072008// File system porting.
2008- #if GTEST_HAS_FILE_SYSTEM
2009+ // Note: Not every I/O-related function is related to file systems, so don't
2010+ // just disable all of them here. For example, fileno() and isatty(), etc. must
2011+ // always be available in order to detect if a pipe points to a terminal.
20092012#ifdef GTEST_OS_WINDOWS
20102013
20112014typedef struct _stat StatStruct;
@@ -2016,27 +2019,32 @@ inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }
20162019// time and thus not defined there.
20172020#else
20182021inline int FileNo (FILE* file) { return _fileno (file); }
2022+ #if GTEST_HAS_FILE_SYSTEM
20192023inline int Stat (const char * path, StatStruct* buf) { return _stat (path, buf); }
20202024inline int RmDir (const char * dir) { return _rmdir (dir); }
20212025inline bool IsDir (const StatStruct& st) { return (_S_IFDIR & st.st_mode ) != 0 ; }
2026+ #endif
20222027#endif // GTEST_OS_WINDOWS_MOBILE
20232028
20242029#elif defined(GTEST_OS_ESP8266)
20252030typedef struct stat StatStruct;
20262031
20272032inline int FileNo (FILE* file) { return fileno (file); }
2033+ #if GTEST_HAS_FILE_SYSTEM
20282034inline int Stat (const char * path, StatStruct* buf) {
20292035 // stat function not implemented on ESP8266
20302036 return 0 ;
20312037}
20322038inline int RmDir (const char * dir) { return rmdir (dir); }
20332039inline bool IsDir (const StatStruct& st) { return S_ISDIR (st.st_mode ); }
2040+ #endif
20342041
20352042#else
20362043
20372044typedef struct stat StatStruct;
20382045
20392046inline int FileNo (FILE* file) { return fileno (file); }
2047+ #if GTEST_HAS_FILE_SYSTEM
20402048inline int Stat (const char * path, StatStruct* buf) { return stat (path, buf); }
20412049#ifdef GTEST_OS_QURT
20422050// QuRT doesn't support any directory functions, including rmdir
@@ -2045,9 +2053,9 @@ inline int RmDir(const char*) { return 0; }
20452053inline int RmDir (const char * dir) { return rmdir (dir); }
20462054#endif
20472055inline bool IsDir (const StatStruct& st) { return S_ISDIR (st.st_mode ); }
2056+ #endif
20482057
20492058#endif // GTEST_OS_WINDOWS
2050- #endif // GTEST_HAS_FILE_SYSTEM
20512059
20522060// Other functions with a different name on Windows.
20532061
@@ -2245,7 +2253,7 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
22452253#endif // !defined(GTEST_FLAG)
22462254
22472255// Pick a command line flags implementation.
2248- #ifdef GTEST_HAS_ABSL
2256+ #ifdef GTEST_INTERNAL_HAS_ABSL_FLAGS
22492257
22502258// Macros for defining flags.
22512259#define GTEST_DEFINE_bool_ (name, default_val, doc ) \
@@ -2270,7 +2278,8 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
22702278 (void )(::absl::SetFlag(>EST_FLAG (name), value))
22712279#define GTEST_USE_OWN_FLAGFILE_FLAG_ 0
22722280
2273- #else // GTEST_HAS_ABSL
2281+ #undef GTEST_INTERNAL_HAS_ABSL_FLAGS
2282+ #else // ndef GTEST_INTERNAL_HAS_ABSL_FLAGS
22742283
22752284// Macros for defining flags.
22762285#define GTEST_DEFINE_bool_ (name, default_val, doc ) \
@@ -2312,7 +2321,7 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
23122321#define GTEST_FLAG_SET (name, value ) (void )(::testing::GTEST_FLAG(name) = value)
23132322#define GTEST_USE_OWN_FLAGFILE_FLAG_ 1
23142323
2315- #endif // GTEST_HAS_ABSL
2324+ #endif // GTEST_INTERNAL_HAS_ABSL_FLAGS
23162325
23172326// Thread annotations
23182327#if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
0 commit comments