diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp index 99454bea783b4634c86508ee9f04514ea59fd9c1..e94d8cb0013eff78e059b5ccf91ca6babd08b524 100644 --- a/BaseLib/FileTools.cpp +++ b/BaseLib/FileTools.cpp @@ -64,6 +64,20 @@ size_t findLastPathSeparator(std::string const& path) return path.find_last_of("/\\"); } +size_t findLastDot(std::string const& path) +{ + return path.find_last_of("."); +} + +std::string dropFileExtension(std::string const& filename) +{ + const size_t p = findLastDot(filename); + if (p == std::string::npos) + return filename; + + return filename.substr(0, filename.length() - p); +} + std::string getFileNameFromPath(const std::string &str, bool with_extension) { std::string::size_type beg1 = str.find_last_of('/');