8383// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that
8484// std::wstring does/doesn't work (Google Test can
8585// be used where std::wstring is unavailable).
86+ // GTEST_HAS_FILE_SYSTEM - Define it to 1/0 to indicate whether or not a
87+ // file system is/isn't available.
8688// GTEST_HAS_SEH - Define it to 1/0 to indicate whether the
8789// compiler supports Microsoft's "Structured
8890// Exception Handling".
@@ -463,6 +465,11 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
463465
464466#endif // GTEST_HAS_STD_WSTRING
465467
468+ #ifndef GTEST_HAS_FILE_SYSTEM
469+ // Most platforms support a file system.
470+ #define GTEST_HAS_FILE_SYSTEM 1
471+ #endif // GTEST_HAS_FILE_SYSTEM
472+
466473// Determines whether RTTI is available.
467474#ifndef GTEST_HAS_RTTI
468475// The user didn't tell us whether RTTI is enabled, so we need to
@@ -580,10 +587,11 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
580587// output correctness and to implement death tests.
581588#ifndef GTEST_HAS_STREAM_REDIRECTION
582589// By default, we assume that stream redirection is supported on all
583- // platforms except known mobile / embedded ones.
590+ // platforms except known mobile / embedded ones. Also, if the port doesn't have
591+ // a file system, stream redirection is not supported.
584592#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \
585593 GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA || \
586- GTEST_OS_QURT
594+ GTEST_OS_QURT || !GTEST_HAS_FILE_SYSTEM
587595#define GTEST_HAS_STREAM_REDIRECTION 0
588596#else
589597#define GTEST_HAS_STREAM_REDIRECTION 1
@@ -599,7 +607,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
599607 GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \
600608 GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_HAIKU || \
601609 GTEST_OS_GNU_HURD)
610+ // Death tests require a file system to work properly.
611+ #if GTEST_HAS_FILE_SYSTEM
602612#define GTEST_HAS_DEATH_TEST 1
613+ #endif // GTEST_HAS_FILE_SYSTEM
603614#endif
604615
605616// Determines whether to support type-driven tests.
@@ -1953,31 +1964,12 @@ inline std::string StripTrailingSpaces(std::string str) {
19531964
19541965namespace posix {
19551966
1956- // Functions with a different name on Windows .
1957-
1967+ // File system porting .
1968+ # if GTEST_HAS_FILE_SYSTEM
19581969#if GTEST_OS_WINDOWS
19591970
19601971typedef struct _stat StatStruct;
19611972
1962- #ifdef __BORLANDC__
1963- inline int DoIsATTY (int fd) { return isatty (fd); }
1964- inline int StrCaseCmp (const char * s1, const char * s2) {
1965- return stricmp (s1, s2);
1966- }
1967- inline char * StrDup (const char * src) { return strdup (src); }
1968- #else // !__BORLANDC__
1969- #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS || GTEST_OS_IOS || \
1970- GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT || defined (ESP_PLATFORM)
1971- inline int DoIsATTY (int /* fd */ ) { return 0 ; }
1972- #else
1973- inline int DoIsATTY (int fd) { return _isatty (fd); }
1974- #endif // GTEST_OS_WINDOWS_MOBILE
1975- inline int StrCaseCmp (const char * s1, const char * s2) {
1976- return _stricmp (s1, s2);
1977- }
1978- inline char * StrDup (const char * src) { return _strdup (src); }
1979- #endif // __BORLANDC__
1980-
19811973#if GTEST_OS_WINDOWS_MOBILE
19821974inline int FileNo (FILE* file) { return reinterpret_cast <int >(_fileno (file)); }
19831975// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this
@@ -1993,15 +1985,10 @@ inline bool IsDir(const StatStruct& st) { return (_S_IFDIR & st.st_mode) != 0; }
19931985typedef struct stat StatStruct;
19941986
19951987inline int FileNo (FILE* file) { return fileno (file); }
1996- inline int DoIsATTY (int fd) { return isatty (fd); }
19971988inline int Stat (const char * path, StatStruct* buf) {
19981989 // stat function not implemented on ESP8266
19991990 return 0 ;
20001991}
2001- inline int StrCaseCmp (const char * s1, const char * s2) {
2002- return strcasecmp (s1, s2);
2003- }
2004- inline char * StrDup (const char * src) { return strdup (src); }
20051992inline int RmDir (const char * dir) { return rmdir (dir); }
20061993inline bool IsDir (const StatStruct& st) { return S_ISDIR (st.st_mode ); }
20071994
@@ -2010,12 +1997,7 @@ inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
20101997typedef struct stat StatStruct;
20111998
20121999inline int FileNo (FILE* file) { return fileno (file); }
2013- inline int DoIsATTY (int fd) { return isatty (fd); }
20142000inline int Stat (const char * path, StatStruct* buf) { return stat (path, buf); }
2015- inline int StrCaseCmp (const char * s1, const char * s2) {
2016- return strcasecmp (s1, s2);
2017- }
2018- inline char * StrDup (const char * src) { return strdup (src); }
20192001#if GTEST_OS_QURT
20202002// QuRT doesn't support any directory functions, including rmdir
20212003inline int RmDir (const char *) { return 0 ; }
@@ -2024,6 +2006,48 @@ inline int RmDir(const char* dir) { return rmdir(dir); }
20242006#endif
20252007inline bool IsDir (const StatStruct& st) { return S_ISDIR (st.st_mode ); }
20262008
2009+ #endif // GTEST_OS_WINDOWS
2010+ #endif // GTEST_HAS_FILE_SYSTEM
2011+
2012+ // Other functions with a different name on Windows.
2013+
2014+ #if GTEST_OS_WINDOWS
2015+
2016+ #ifdef __BORLANDC__
2017+ inline int DoIsATTY (int fd) { return isatty (fd); }
2018+ inline int StrCaseCmp (const char * s1, const char * s2) {
2019+ return stricmp (s1, s2);
2020+ }
2021+ inline char * StrDup (const char * src) { return strdup (src); }
2022+ #else // !__BORLANDC__
2023+ #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS || GTEST_OS_IOS || \
2024+ GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT || defined (ESP_PLATFORM)
2025+ inline int DoIsATTY (int /* fd */ ) { return 0 ; }
2026+ #else
2027+ inline int DoIsATTY (int fd) { return _isatty (fd); }
2028+ #endif // GTEST_OS_WINDOWS_MOBILE
2029+ inline int StrCaseCmp (const char * s1, const char * s2) {
2030+ return _stricmp (s1, s2);
2031+ }
2032+ inline char * StrDup (const char * src) { return _strdup (src); }
2033+ #endif // __BORLANDC__
2034+
2035+ #elif GTEST_OS_ESP8266
2036+
2037+ inline int DoIsATTY (int fd) { return isatty (fd); }
2038+ inline int StrCaseCmp (const char * s1, const char * s2) {
2039+ return strcasecmp (s1, s2);
2040+ }
2041+ inline char * StrDup (const char * src) { return strdup (src); }
2042+
2043+ #else
2044+
2045+ inline int DoIsATTY (int fd) { return isatty (fd); }
2046+ inline int StrCaseCmp (const char * s1, const char * s2) {
2047+ return strcasecmp (s1, s2);
2048+ }
2049+ inline char * StrDup (const char * src) { return strdup (src); }
2050+
20272051#endif // GTEST_OS_WINDOWS
20282052
20292053inline int IsATTY (int fd) {
@@ -2044,7 +2068,7 @@ GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
20442068// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
20452069// StrError() aren't needed on Windows CE at this time and thus not
20462070// defined there.
2047-
2071+ # if GTEST_HAS_FILE_SYSTEM
20482072#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && \
20492073 !GTEST_OS_WINDOWS_RT && !GTEST_OS_ESP8266 && !GTEST_OS_XTENSA && \
20502074 !GTEST_OS_QURT
@@ -2066,7 +2090,7 @@ inline FILE* FReopen(const char* path, const char* mode, FILE* stream) {
20662090 return freopen (path, mode, stream);
20672091}
20682092inline FILE* FDOpen (int fd, const char * mode) { return fdopen (fd, mode); }
2069- #endif
2093+ #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
20702094inline int FClose (FILE* fp) { return fclose (fp); }
20712095#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
20722096inline int Read (int fd, void * buf, unsigned int count) {
@@ -2076,8 +2100,13 @@ inline int Write(int fd, const void* buf, unsigned int count) {
20762100 return static_cast <int >(write (fd, buf, count));
20772101}
20782102inline int Close (int fd) { return close (fd); }
2103+ #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
2104+ #endif // GTEST_HAS_FILE_SYSTEM
2105+
2106+ #if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
20792107inline const char * StrError (int errnum) { return strerror (errnum); }
2080- #endif
2108+ #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
2109+
20812110inline const char * GetEnv (const char * name) {
20822111#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \
20832112 GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA || \
0 commit comments