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
| 7584 | // not have a file, like "just/a/dir/", it returns the FilePath unmodified. |
| 7585 | // On Windows platform, '\' is the path separator, otherwise it is '/'. |
| 7586 | FilePath FilePath::RemoveFileName() const { |
| 7587 | const char* const last_sep = FindLastPathSeparator(); |
| 7588 | String dir; |
| 7589 | if (last_sep) { |
| 7590 | dir = String(c_str(), last_sep + 1 - c_str()); |
| 7591 | } else { |
| 7592 | dir = kCurrentDirectoryString; |
| 7593 | } |
| 7594 | return FilePath(dir); |
| 7595 | } |
| 7596 | |
| 7597 | // Helper functions for naming files in a directory for xml output. |
| 7598 |
no test coverage detected