Returns a pointer to the last occurence of a valid path separator in the FilePath. On Windows, for example, both '/' and '\' are valid path separators. Returns NULL if no path separator was found.
| 7963 | // the FilePath. On Windows, for example, both '/' and '\' are valid path |
| 7964 | // separators. Returns NULL if no path separator was found. |
| 7965 | const char* FilePath::FindLastPathSeparator() const { |
| 7966 | const char* const last_sep = strrchr(c_str(), kPathSeparator); |
| 7967 | #if GTEST_HAS_ALT_PATH_SEP_ |
| 7968 | const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator); |
| 7969 | // Comparing two pointers of which only one is NULL is undefined. |
| 7970 | if (last_alt_sep != NULL && |
| 7971 | (last_sep == NULL || last_alt_sep > last_sep)) { |
| 7972 | return last_alt_sep; |
| 7973 | } |
| 7974 | #endif |
| 7975 | return last_sep; |
| 7976 | } |
| 7977 | |
| 7978 | // Returns a copy of the FilePath with the directory part removed. |
| 7979 | // Example: FilePath("path/to/file").RemoveDirectoryName() returns |