diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp index dbece13df5f499f9d73df925fd38245f51eb3512..22dbb223463c164eb0890d470ed4dd5dc4d41ed4 100644 --- a/BaseLib/FileTools.cpp +++ b/BaseLib/FileTools.cpp @@ -80,6 +80,16 @@ std::string getFileNameFromPath(const std::string &str, bool with_extension) return file.substr(0,end); } +std::string extractBaseName(std::string const& pathname) +{ + return getFileNameFromPath(pathname, true); +} + +std::string extractBaseNameWithoutExtension(std::string const& pathname) +{ + return getFileNameFromPath(pathname, false); +} + std::string getSuffixFromPath(const std::string &path) { const std::string str = getFileNameFromPath(path, true); diff --git a/BaseLib/FileTools.h b/BaseLib/FileTools.h index 970146c5e69bf10f7ecde90e13cabb12d877c7c7..d85cabd9ce3e24796dcd87c5e8a1c36673b06184 100644 --- a/BaseLib/FileTools.h +++ b/BaseLib/FileTools.h @@ -59,6 +59,16 @@ void truncateFile( std::string const& file_path); */ std::string getFileNameFromPath(const std::string &str, bool with_extension = false); +/** + * Extracts basename from given pathname with extension. + */ +std::string extractBaseName(std::string const& pathname); + +/** + * Extracts basename from given pathname without its extension. + */ +std::string extractBaseNameWithoutExtension(std::string const& pathname); + /** * Extract the file type / suffix from a path */