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 =
'/';
74 const char kAlternatePathSeparatorString[] =
"/";
75 # if GTEST_OS_WINDOWS_MOBILE 81 const DWORD kInvalidFileAttributes = 0xffffffff;
83 const char kCurrentDirectoryString[] =
".\\";
84 # endif // GTEST_OS_WINDOWS_MOBILE 86 const char kPathSeparator =
'/';
87 const char kPathSeparatorString[] =
"/";
88 const char kCurrentDirectoryString[] =
"./";
89 #endif // GTEST_OS_WINDOWS 93 #if GTEST_HAS_ALT_PATH_SEP_ 94 return (c == kPathSeparator) || (c == kAlternatePathSeparator);
102 #if GTEST_OS_WINDOWS_MOBILE 105 return FilePath(kCurrentDirectoryString);
106 #elif GTEST_OS_WINDOWS 108 return FilePath(_getcwd(cwd,
sizeof(cwd)) == NULL ?
"" : cwd);
111 return FilePath(getcwd(cwd,
sizeof(cwd)) == NULL ?
"" : cwd);
112 #endif // GTEST_OS_WINDOWS_MOBILE 123 0,
pathname_.length() - dot_extension.length()));
132 const char*
const last_sep = strrchr(
c_str(), kPathSeparator);
133 #if GTEST_HAS_ALT_PATH_SEP_ 134 const char*
const last_alt_sep = strrchr(
c_str(), kAlternatePathSeparator);
136 if (last_alt_sep != NULL &&
137 (last_sep == NULL || last_alt_sep > last_sep)) {
152 return last_sep ?
FilePath(last_sep + 1) : *
this;
181 const char* extension) {
184 file = base_name.
string() +
"." + extension;
197 return relative_path;
199 return FilePath(dir.string() + kPathSeparator + relative_path.
string());
205 #if GTEST_OS_WINDOWS_MOBILE 206 LPCWSTR unicode = String::AnsiToUtf16(
pathname_.c_str());
207 const DWORD attributes = GetFileAttributes(unicode);
209 return attributes != kInvalidFileAttributes;
213 #endif // GTEST_OS_WINDOWS_MOBILE 229 #if GTEST_OS_WINDOWS_MOBILE 230 LPCWSTR unicode = String::AnsiToUtf16(path.
c_str());
231 const DWORD attributes = GetFileAttributes(unicode);
233 if ((attributes != kInvalidFileAttributes) &&
234 (attributes & FILE_ATTRIBUTE_DIRECTORY)) {
241 #endif // GTEST_OS_WINDOWS_MOBILE 264 ((name[0] >=
'a' && name[0] <=
'z') ||
265 (name[0] >=
'A' && name[0] <=
'Z')) &&
283 const char* extension) {
287 full_pathname.
Set(
MakeFileName(directory, base_name, number++, extension));
289 return full_pathname;
321 #if GTEST_OS_WINDOWS_MOBILE 323 LPCWSTR unicode = String::AnsiToUtf16(removed_sep.
c_str());
324 int result = CreateDirectory(unicode, NULL) ? 0 : -1;
326 #elif GTEST_OS_WINDOWS 329 int result = mkdir(
pathname_.c_str(), 0777);
330 #endif // GTEST_OS_WINDOWS_MOBILE 357 char*
const dest =
new char[
pathname_.length() + 1];
358 char* dest_ptr = dest;
359 memset(dest_ptr, 0,
pathname_.length() + 1);
361 while (*src !=
'\0') {
366 #if GTEST_HAS_ALT_PATH_SEP_ 367 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)
const char kPathSeparatorString[]
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
FilePath RemoveExtension(const char *extension) const
const char kPathSeparator