Returns a pointer to the last occurrence 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.
| 7554 | // the FilePath. On Windows, for example, both '/' and '\' are valid path |
| 7555 | // separators. Returns NULL if no path separator was found. |
| 7556 | const char* FilePath::FindLastPathSeparator() const { |
| 7557 | const char* const last_sep = strrchr(c_str(), kPathSeparator); |
| 7558 | #if GTEST_HAS_ALT_PATH_SEP_ |
| 7559 | const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator); |
| 7560 | // Comparing two pointers of which only one is NULL is undefined. |
| 7561 | if (last_alt_sep != NULL && |
| 7562 | (last_sep == NULL || last_alt_sep > last_sep)) { |
| 7563 | return last_alt_sep; |
| 7564 | } |
| 7565 | #endif |
| 7566 | return last_sep; |
| 7567 | } |
| 7568 | |
| 7569 | // Returns a copy of the FilePath with the directory part removed. |
| 7570 | // Example: FilePath("path/to/file").RemoveDirectoryName() returns |