diff options
author | shiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925> | 2008-09-26 16:08:30 +0000 |
---|---|---|
committer | shiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925> | 2008-09-26 16:08:30 +0000 |
commit | f0e809a3c9946e99595d4faeb0a16bdc2ca9ffd5 (patch) | |
tree | 68f49941b72ce8f866c4f762cb3043504804800f /include/gtest/internal/gtest-filepath.h | |
parent | dc8c9fa9f38a6a8fc2b78d8096e8d3f1c969cb7c (diff) | |
download | googletest-f0e809a3c9946e99595d4faeb0a16bdc2ca9ffd5.tar.gz |
Lots of changes:
* changes the XML report format to match JUnit/Ant's.
* improves file path handling.
* allows the user to disable RTTI using the GTEST_HAS_RTTI macro.
* makes the code compile with -Wswitch-enum.
git-svn-id: http://googletest.googlecode.com/svn/trunk@98 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'include/gtest/internal/gtest-filepath.h')
-rw-r--r-- | include/gtest/internal/gtest-filepath.h | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/include/gtest/internal/gtest-filepath.h b/include/gtest/internal/gtest-filepath.h index fecdddc..9a0682a 100644 --- a/include/gtest/internal/gtest-filepath.h +++ b/include/gtest/internal/gtest-filepath.h @@ -60,8 +60,19 @@ class FilePath { public: FilePath() : pathname_("") { } FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { } - explicit FilePath(const char* pathname) : pathname_(pathname) { } - explicit FilePath(const String& pathname) : pathname_(pathname) { } + + explicit FilePath(const char* pathname) : pathname_(pathname) { + Normalize(); + } + + explicit FilePath(const String& pathname) : pathname_(pathname) { + Normalize(); + } + + FilePath& operator=(const FilePath& rhs) { + Set(rhs); + return *this; + } void Set(const FilePath& rhs) { pathname_ = rhs.pathname_; @@ -149,11 +160,30 @@ class FilePath { // This does NOT check that a directory (or file) actually exists. bool IsDirectory() const; + // Returns true if pathname describes a root directory. (Windows has one + // root directory per disk drive.) + bool IsRootDirectory() const; + private: - String pathname_; + // Replaces multiple consecutive separators with a single separator. + // For example, "bar///foo" becomes "bar/foo". Does not eliminate other + // redundancies that might be in a pathname involving "." or "..". + // + // A pathname with multiple consecutive separators may occur either through + // user error or as a result of some scripts or APIs that generate a pathname + // with a trailing separator. On other platforms the same API or script + // may NOT generate a pathname with a trailing "/". Then elsewhere that + // pathname may have another "/" and pathname components added to it, + // without checking for the separator already being there. + // The script language and operating system may allow paths like "foo//bar" + // but some of the functions in FilePath will not handle that correctly. In + // particular, RemoveTrailingPathSeparator() only removes one separator, and + // it is called in CreateDirectoriesRecursively() assuming that it will change + // a pathname from directory syntax (trailing separator) to filename syntax. + + void Normalize(); - // Don't implement operator= because it is banned by the style guide. - FilePath& operator=(const FilePath& rhs); + String pathname_; }; // class FilePath } // namespace internal |