* Gets the base filename of a path. * @param path Full path to file. * @param transform Optional function to transform the filename. * @return Base filename. */
| 657 | * @return Base filename. |
| 658 | */ |
| 659 | std::string baseFilename(const std::string &path, int (*transform)(int)) |
| 660 | { |
| 661 | size_t sep = path.find_last_of(PATH_SEPARATOR); |
| 662 | std::string filename; |
| 663 | if (sep == std::string::npos) |
| 664 | { |
| 665 | filename = path; |
| 666 | } |
| 667 | else |
| 668 | { |
| 669 | filename = path.substr(0, sep + 1); |
| 670 | } |
| 671 | if (transform != 0) |
| 672 | { |
| 673 | std::transform(filename.begin(), filename.end(), filename.begin(), transform); |
| 674 | } |
| 675 | return filename; |
| 676 | } |
| 677 | |
| 678 | /** |
| 679 | * Replaces invalid filesystem characters with _. |
nothing calls this directly
no outgoing calls
no test coverage detected