MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / baseFilename

Function baseFilename

src/Engine/CrossPlatform.cpp:659–676  ·  view source on GitHub ↗

* Gets the base filename of a path. * @param path Full path to file. * @param transform Optional function to transform the filename. * @return Base filename. */

Source from the content-addressed store, hash-verified

657 * @return Base filename.
658 */
659std::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 _.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected