From f1523c115c846c6e6f70b1fba0562509f613a39c Mon Sep 17 00:00:00 2001 From: Dmitrij Naumov <dmitrij@naumov.de> Date: Wed, 31 Oct 2012 23:15:05 +0100 Subject: [PATCH] Improve docs. --- BaseLib/FileTools.cpp | 6 ++++++ BaseLib/FileTools.h | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp index 4be8108333e..efb8a65e76e 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 78d7b1e6c0b..50cbc3282d5 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 -- GitLab