RemoveFileName returns the directory path with the filename removed. Example: FilePath("path/to/file").RemoveFileName() returns "path/to/". If the FilePath is "a_file" or "/a_file", RemoveFileName returns FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does not have a file, like "just/a/dir/", it returns the FilePath unmodified. On Windows platform, '\' is the path separator, other
| 9397 | // not have a file, like "just/a/dir/", it returns the FilePath unmodified. |
| 9398 | // On Windows platform, '\' is the path separator, otherwise it is '/'. |
| 9399 | FilePath FilePath::RemoveFileName() const { |
| 9400 | const char* const last_sep = FindLastPathSeparator(); |
| 9401 | std::string dir; |
| 9402 | if (last_sep) { |
| 9403 | dir = std::string(c_str(), static_cast<size_t>(last_sep + 1 - c_str())); |
| 9404 | } else { |
| 9405 | dir = kCurrentDirectoryString; |
| 9406 | } |
| 9407 | return FilePath(dir); |
| 9408 | } |
| 9409 | |
| 9410 | // Helper functions for naming files in a directory for xml output. |
| 9411 |
no test coverage detected