83
83
// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that
84
84
// std::wstring does/doesn't work (Google Test can
85
85
// 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.
86
88
// GTEST_HAS_SEH - Define it to 1/0 to indicate whether the
87
89
// compiler supports Microsoft's "Structured
88
90
// Exception Handling".
@@ -463,6 +465,11 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
463
465
464
466
#endif // GTEST_HAS_STD_WSTRING
465
467
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
+
466
473
// Determines whether RTTI is available.
467
474
#ifndef GTEST_HAS_RTTI
468
475
// 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;
580
587
// output correctness and to implement death tests.
581
588
#ifndef GTEST_HAS_STREAM_REDIRECTION
582
589
// 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.
584
592
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \
585
593
GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA || \
586
- GTEST_OS_QURT
594
+ GTEST_OS_QURT || !GTEST_HAS_FILE_SYSTEM
587
595
#define GTEST_HAS_STREAM_REDIRECTION 0
588
596
#else
589
597
#define GTEST_HAS_STREAM_REDIRECTION 1
@@ -599,7 +607,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
599
607
GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \
600
608
GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_HAIKU || \
601
609
GTEST_OS_GNU_HURD)
610
+ // Death tests require a file system to work properly.
611
+ #if GTEST_HAS_FILE_SYSTEM
602
612
#define GTEST_HAS_DEATH_TEST 1
613
+ #endif // GTEST_HAS_FILE_SYSTEM
603
614
#endif
604
615
605
616
// Determines whether to support type-driven tests.
@@ -1953,31 +1964,12 @@ inline std::string StripTrailingSpaces(std::string str) {
1953
1964
1954
1965
namespace posix {
1955
1966
1956
- // Functions with a different name on Windows .
1957
-
1967
+ // File system porting .
1968
+ # if GTEST_HAS_FILE_SYSTEM
1958
1969
#if GTEST_OS_WINDOWS
1959
1970
1960
1971
typedef struct _stat StatStruct;
1961
1972
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
-
1981
1973
#if GTEST_OS_WINDOWS_MOBILE
1982
1974
inline int FileNo (FILE* file) { return reinterpret_cast <int >(_fileno (file)); }
1983
1975
// 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; }
1993
1985
typedef struct stat StatStruct;
1994
1986
1995
1987
inline int FileNo (FILE* file) { return fileno (file); }
1996
- inline int DoIsATTY (int fd) { return isatty (fd); }
1997
1988
inline int Stat (const char * path, StatStruct* buf) {
1998
1989
// stat function not implemented on ESP8266
1999
1990
return 0 ;
2000
1991
}
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); }
2005
1992
inline int RmDir (const char * dir) { return rmdir (dir); }
2006
1993
inline bool IsDir (const StatStruct& st) { return S_ISDIR (st.st_mode ); }
2007
1994
@@ -2010,12 +1997,7 @@ inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
2010
1997
typedef struct stat StatStruct;
2011
1998
2012
1999
inline int FileNo (FILE* file) { return fileno (file); }
2013
- inline int DoIsATTY (int fd) { return isatty (fd); }
2014
2000
inline 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); }
2019
2001
#if GTEST_OS_QURT
2020
2002
// QuRT doesn't support any directory functions, including rmdir
2021
2003
inline int RmDir (const char *) { return 0 ; }
@@ -2024,6 +2006,48 @@ inline int RmDir(const char* dir) { return rmdir(dir); }
2024
2006
#endif
2025
2007
inline bool IsDir (const StatStruct& st) { return S_ISDIR (st.st_mode ); }
2026
2008
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
+
2027
2051
#endif // GTEST_OS_WINDOWS
2028
2052
2029
2053
inline int IsATTY (int fd) {
@@ -2044,7 +2068,7 @@ GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
2044
2068
// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
2045
2069
// StrError() aren't needed on Windows CE at this time and thus not
2046
2070
// defined there.
2047
-
2071
+ # if GTEST_HAS_FILE_SYSTEM
2048
2072
#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && \
2049
2073
!GTEST_OS_WINDOWS_RT && !GTEST_OS_ESP8266 && !GTEST_OS_XTENSA && \
2050
2074
!GTEST_OS_QURT
@@ -2066,7 +2090,7 @@ inline FILE* FReopen(const char* path, const char* mode, FILE* stream) {
2066
2090
return freopen (path, mode, stream);
2067
2091
}
2068
2092
inline FILE* FDOpen (int fd, const char * mode) { return fdopen (fd, mode); }
2069
- #endif
2093
+ #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
2070
2094
inline int FClose (FILE* fp) { return fclose (fp); }
2071
2095
#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
2072
2096
inline int Read (int fd, void * buf, unsigned int count) {
@@ -2076,8 +2100,13 @@ inline int Write(int fd, const void* buf, unsigned int count) {
2076
2100
return static_cast <int >(write (fd, buf, count));
2077
2101
}
2078
2102
inline 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
2079
2107
inline const char * StrError (int errnum) { return strerror (errnum); }
2080
- #endif
2108
+ #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT
2109
+
2081
2110
inline const char * GetEnv (const char * name) {
2082
2111
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \
2083
2112
GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA || \
0 commit comments