tesseract v5.3.3.20231005
testing::internal::posix Namespace Reference

Typedefs

typedef struct stat StatStruct
 

Functions

int FileNo (FILE *file)
 
int DoIsATTY (int fd)
 
int Stat (const char *path, StatStruct *buf)
 
int StrCaseCmp (const char *s1, const char *s2)
 
char * StrDup (const char *src)
 
int RmDir (const char *dir)
 
bool IsDir (const StatStruct &st)
 
int IsATTY (int fd)
 
int ChDir (const char *dir)
 
FILE * FOpen (const char *path, const char *mode)
 
FILE * FReopen (const char *path, const char *mode, FILE *stream)
 
FILE * FDOpen (int fd, const char *mode)
 
int FClose (FILE *fp)
 
int Read (int fd, void *buf, unsigned int count)
 
int Write (int fd, const void *buf, unsigned int count)
 
int Close (int fd)
 
const char * StrError (int errnum)
 
const char * GetEnv (const char *name)
 
void Abort ()
 

Typedef Documentation

◆ StatStruct

Definition at line 2038 of file gtest-port.h.

Function Documentation

◆ Abort()

void testing::internal::posix::Abort ( )
inline

Definition at line 2127 of file gtest-port.h.

2127{ abort(); }

◆ ChDir()

int testing::internal::posix::ChDir ( const char *  dir)
inline

Definition at line 2073 of file gtest-port.h.

2073{ return chdir(dir); }

◆ Close()

int testing::internal::posix::Close ( int  fd)
inline

Definition at line 2100 of file gtest-port.h.

2100{ return close(fd); }

◆ DoIsATTY()

int testing::internal::posix::DoIsATTY ( int  fd)
inline

Definition at line 2041 of file gtest-port.h.

2041{ return isatty(fd); }

◆ FClose()

int testing::internal::posix::FClose ( FILE *  fp)
inline

Definition at line 2092 of file gtest-port.h.

2092{ return fclose(fp); }

◆ FDOpen()

FILE * testing::internal::posix::FDOpen ( int  fd,
const char *  mode 
)
inline

Definition at line 2090 of file gtest-port.h.

2090{ return fdopen(fd, mode); }

◆ FileNo()

int testing::internal::posix::FileNo ( FILE *  file)
inline

Definition at line 2040 of file gtest-port.h.

2040{ return fileno(file); }

◆ FOpen()

FILE * testing::internal::posix::FOpen ( const char *  path,
const char *  mode 
)
inline

Definition at line 2075 of file gtest-port.h.

2075 {
2076#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
2077 struct wchar_codecvt : public std::codecvt<wchar_t, char, std::mbstate_t> {};
2078 std::wstring_convert<wchar_codecvt> converter;
2079 std::wstring wide_path = converter.from_bytes(path);
2080 std::wstring wide_mode = converter.from_bytes(mode);
2081 return _wfopen(wide_path.c_str(), wide_mode.c_str());
2082#else // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
2083 return fopen(path, mode);
2084#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
2085}

◆ FReopen()

FILE * testing::internal::posix::FReopen ( const char *  path,
const char *  mode,
FILE *  stream 
)
inline

Definition at line 2087 of file gtest-port.h.

2087 {
2088 return freopen(path, mode, stream);
2089}

◆ GetEnv()

const char * testing::internal::posix::GetEnv ( const char *  name)
inline

Definition at line 2103 of file gtest-port.h.

2103 {
2104#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \
2105 GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA
2106 // We are on an embedded platform, which has no environment variables.
2107 static_cast<void>(name); // To prevent 'unused argument' warning.
2108 return nullptr;
2109#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
2110 // Environment variables which we programmatically clear will be set to the
2111 // empty string rather than unset (NULL). Handle that case.
2112 const char* const env = getenv(name);
2113 return (env != nullptr && env[0] != '\0') ? env : nullptr;
2114#else
2115 return getenv(name);
2116#endif
2117}

◆ IsATTY()

int testing::internal::posix::IsATTY ( int  fd)
inline

Definition at line 2052 of file gtest-port.h.

2052 {
2053 // DoIsATTY might change errno (for example ENOTTY in case you redirect stdout
2054 // to a file on Linux), which is unexpected, so save the previous value, and
2055 // restore it after the call.
2056 int savedErrno = errno;
2057 int isAttyValue = DoIsATTY(fd);
2058 errno = savedErrno;
2059
2060 return isAttyValue;
2061}

◆ IsDir()

bool testing::internal::posix::IsDir ( const StatStruct st)
inline

Definition at line 2048 of file gtest-port.h.

2048{ return S_ISDIR(st.st_mode); }

◆ Read()

int testing::internal::posix::Read ( int  fd,
void *  buf,
unsigned int  count 
)
inline

Definition at line 2094 of file gtest-port.h.

2094 {
2095 return static_cast<int>(read(fd, buf, count));
2096}
int * count

◆ RmDir()

int testing::internal::posix::RmDir ( const char *  dir)
inline

Definition at line 2047 of file gtest-port.h.

2047{ return rmdir(dir); }

◆ Stat()

int testing::internal::posix::Stat ( const char *  path,
StatStruct buf 
)
inline

Definition at line 2042 of file gtest-port.h.

2042{ return stat(path, buf); }

◆ StrCaseCmp()

int testing::internal::posix::StrCaseCmp ( const char *  s1,
const char *  s2 
)
inline

Definition at line 2043 of file gtest-port.h.

2043 {
2044 return strcasecmp(s1, s2);
2045}

◆ StrDup()

char * testing::internal::posix::StrDup ( const char *  src)
inline

Definition at line 2046 of file gtest-port.h.

2046{ return strdup(src); }

◆ StrError()

const char * testing::internal::posix::StrError ( int  errnum)
inline

Definition at line 2101 of file gtest-port.h.

2101{ return strerror(errnum); }

◆ Write()

int testing::internal::posix::Write ( int  fd,
const void *  buf,
unsigned int  count 
)
inline

Definition at line 2097 of file gtest-port.h.

2097 {
2098 return static_cast<int>(write(fd, buf, count));
2099}