123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
- #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
- #include "gtest/internal/gtest-string.h"
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
- )
- namespace testing {
- namespace internal {
- class GTEST_API_ FilePath {
- public:
- FilePath() : pathname_("") { }
- FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
- explicit FilePath(const std::string& pathname) : pathname_(pathname) {
- Normalize();
- }
- FilePath& operator=(const FilePath& rhs) {
- Set(rhs);
- return *this;
- }
- void Set(const FilePath& rhs) {
- pathname_ = rhs.pathname_;
- }
- const std::string& string() const { return pathname_; }
- const char* c_str() const { return pathname_.c_str(); }
-
- static FilePath GetCurrentDir();
-
-
-
-
- static FilePath MakeFileName(const FilePath& directory,
- const FilePath& base_name,
- int number,
- const char* extension);
-
-
-
- static FilePath ConcatPaths(const FilePath& directory,
- const FilePath& relative_path);
-
-
-
-
-
-
-
-
- static FilePath GenerateUniqueFileName(const FilePath& directory,
- const FilePath& base_name,
- const char* extension);
-
- bool IsEmpty() const { return pathname_.empty(); }
-
-
-
- FilePath RemoveTrailingPathSeparator() const;
-
-
-
-
-
-
- FilePath RemoveDirectoryName() const;
-
-
-
-
-
-
- FilePath RemoveFileName() const;
-
-
-
-
- FilePath RemoveExtension(const char* extension) const;
-
-
-
-
- bool CreateDirectoriesRecursively() const;
-
-
-
-
- bool CreateFolder() const;
-
-
- bool FileOrDirectoryExists() const;
-
-
- bool DirectoryExists() const;
-
-
-
- bool IsDirectory() const;
-
-
- bool IsRootDirectory() const;
-
- bool IsAbsolutePath() const;
- private:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void Normalize();
-
-
-
- const char* FindLastPathSeparator() const;
- std::string pathname_;
- };
- }
- }
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
|