32 #include "gtest/gtest-message.h" 33 #include "gtest/internal/gtest-filepath.h" 34 #include "gtest/internal/gtest-port.h" 38 #if GTEST_OS_WINDOWS_MOBILE 40 #elif GTEST_OS_WINDOWS 43 #elif GTEST_OS_SYMBIAN 45 # include <sys/syslimits.h> 49 #endif // GTEST_OS_WINDOWS_MOBILE 52 # define GTEST_PATH_MAX_ _MAX_PATH 53 #elif defined(PATH_MAX) 54 # define GTEST_PATH_MAX_ PATH_MAX 55 #elif defined(_XOPEN_PATH_MAX) 56 # define GTEST_PATH_MAX_ _XOPEN_PATH_MAX 58 # define GTEST_PATH_MAX_ _POSIX_PATH_MAX 59 #endif // GTEST_OS_WINDOWS 61 #include "gtest/internal/gtest-string.h" 72 const char kAlternatePathSeparator =
'/';
73 const char kAlternatePathSeparatorString[] =
"/";
74 # if GTEST_OS_WINDOWS_MOBILE 80 const DWORD kInvalidFileAttributes = 0xffffffff;
82 const char kCurrentDirectoryString[] =
".\\";
83 # endif // GTEST_OS_WINDOWS_MOBILE 85 const char kPathSeparator =
'/';
86 const char kCurrentDirectoryString[] =
"./";
87 #endif // GTEST_OS_WINDOWS 91 #if GTEST_HAS_ALT_PATH_SEP_ 92 return (c == kPathSeparator) || (c == kAlternatePathSeparator);
100 #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT 103 return FilePath(kCurrentDirectoryString);
104 #elif GTEST_OS_WINDOWS 106 return FilePath(_getcwd(cwd,
sizeof(cwd)) == NULL ?
"" : cwd);
109 char* result = getcwd(cwd,
sizeof(cwd));
114 return FilePath(result == NULL ? kCurrentDirectoryString : cwd);
115 # endif // GTEST_OS_NACL 116 return FilePath(result == NULL ?
"" : cwd);
117 #endif // GTEST_OS_WINDOWS_MOBILE 128 0,
pathname_.length() - dot_extension.length()));
137 const char*
const last_sep = strrchr(
c_str(), kPathSeparator);
138 #if GTEST_HAS_ALT_PATH_SEP_ 139 const char*
const last_alt_sep = strrchr(
c_str(), kAlternatePathSeparator);
141 if (last_alt_sep != NULL &&
142 (last_sep == NULL || last_alt_sep > last_sep)) {
157 return last_sep ?
FilePath(last_sep + 1) : *
this;
186 const char* extension) {
189 file = base_name.
string() +
"." + extension;
202 return relative_path;
204 return FilePath(dir.string() + kPathSeparator + relative_path.
string());
210 #if GTEST_OS_WINDOWS_MOBILE 211 LPCWSTR unicode = String::AnsiToUtf16(
pathname_.c_str());
212 const DWORD attributes = GetFileAttributes(unicode);
214 return attributes != kInvalidFileAttributes;
218 #endif // GTEST_OS_WINDOWS_MOBILE 234 #if GTEST_OS_WINDOWS_MOBILE 235 LPCWSTR unicode = String::AnsiToUtf16(path.
c_str());
236 const DWORD attributes = GetFileAttributes(unicode);
238 if ((attributes != kInvalidFileAttributes) &&
239 (attributes & FILE_ATTRIBUTE_DIRECTORY)) {
246 #endif // GTEST_OS_WINDOWS_MOBILE 269 ((name[0] >=
'a' && name[0] <=
'z') ||
270 (name[0] >=
'A' && name[0] <=
'Z')) &&
288 const char* extension) {
292 full_pathname.
Set(
MakeFileName(directory, base_name, number++, extension));
294 return full_pathname;
326 #if GTEST_OS_WINDOWS_MOBILE 328 LPCWSTR unicode = String::AnsiToUtf16(removed_sep.
c_str());
329 int result = CreateDirectory(unicode, NULL) ? 0 : -1;
331 #elif GTEST_OS_WINDOWS 334 int result = mkdir(
pathname_.c_str(), 0777);
335 #endif // GTEST_OS_WINDOWS_MOBILE 363 char* dest_ptr =
dest;
364 memset(dest_ptr, 0,
pathname_.length() + 1);
366 while (*src !=
'\0') {
371 #if GTEST_HAS_ALT_PATH_SEP_ 372 if (*dest_ptr == kAlternatePathSeparator) {
static FilePath ConcatPaths(const FilePath &directory, const FilePath &relative_path)
static bool EndsWithCaseInsensitive(const std::string &str, const std::string &suffix)
bool FileOrDirectoryExists() const
int Stat(const char *path, StatStruct *buf)
bool CreateDirectoriesRecursively() const
std::string StreamableToString(const T &streamable)
const char kCurrentDirectoryString[]
bool CreateFolder() const
void Set(const FilePath &rhs)
FilePath RemoveFileName() const
const std::string & string() const
FilePath RemoveTrailingPathSeparator() const
bool IsDir(const StatStruct &st)
const char * c_str() const
static FilePath GenerateUniqueFileName(const FilePath &directory, const FilePath &base_name, const char *extension)
bool IsRootDirectory() const
bool IsAbsolutePath() const
const char * FindLastPathSeparator() const
static FilePath GetCurrentDir()
static FilePath MakeFileName(const FilePath &directory, const FilePath &base_name, int number, const char *extension)
static bool IsPathSeparator(char c)
FilePath RemoveDirectoryName() const
bool DirectoryExists() const
folly::Function< void()> parent
FilePath RemoveExtension(const char *extension) const
const char kPathSeparator