diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp index 4be8108333ec9f5e62dd93a885c7eef667aa4d6e..efb8a65e76ea314e03a1e65898a6dcd50952e275 100644 --- a/BaseLib/FileTools.cpp +++ b/BaseLib/FileTools.cpp @@ -71,11 +71,17 @@ size_t findLastPathSeparator(std::string const& path) return path.find_last_of("/\\"); } +/** Finds the position of last dot. + * This could be used to extract file extension. + */ size_t findLastDot(std::string const& path) { return path.find_last_of("."); } +/** Returns a string with file extension as found by getFileExtension() + * dropped. + */ std::string dropFileExtension(std::string const& filename) { const size_t p = findLastDot(filename); diff --git a/BaseLib/FileTools.h b/BaseLib/FileTools.h index 78d7b1e6c0bd28716a76e392ed9b7040cf0f5c42..50cbc3282d56fc74b3cce165f7eb2def11596584 100644 --- a/BaseLib/FileTools.h +++ b/BaseLib/FileTools.h @@ -49,11 +49,17 @@ void truncateFile( std::string const& file_path); /** * Extracts basename from given pathname with extension. + * + * Returns a string containing everything after the last path separator. + * If the the pathname does not contain a path separator original pathname is + * returned. */ std::string extractBaseName(std::string const& pathname); /** * Extracts basename from given pathname without its extension. + * + * Same as extractBaseName(), but drops the file extension too. */ std::string extractBaseNameWithoutExtension(std::string const& pathname); @@ -70,12 +76,15 @@ std::string getFileExtension(std::string const& filename); bool hasFileExtension(std::string const& extension, std::string const& filename); /** - * Checks if file_name already contains a qualified path and if not copies the path from source. + * Checks if file_name already contains a qualified path and if not copies the + * path from source. */ std::string copyPathToFileName(const std::string &file_name, const std::string &source); /** * Extracts the path of a pathname. + * + * Returns a string up to the last path separator not including it. */ std::string extractPath(std::string const& pathname); } // end namespace BaseLib