Skip to content
Snippets Groups Projects
Commit f1523c11 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

Improve docs.

parent f7c8284a
No related branches found
No related tags found
No related merge requests found
...@@ -71,11 +71,17 @@ size_t findLastPathSeparator(std::string const& path) ...@@ -71,11 +71,17 @@ size_t findLastPathSeparator(std::string const& path)
return path.find_last_of("/\\"); 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) size_t findLastDot(std::string const& path)
{ {
return path.find_last_of("."); return path.find_last_of(".");
} }
/** Returns a string with file extension as found by getFileExtension()
* dropped.
*/
std::string dropFileExtension(std::string const& filename) std::string dropFileExtension(std::string const& filename)
{ {
const size_t p = findLastDot(filename); const size_t p = findLastDot(filename);
......
...@@ -49,11 +49,17 @@ void truncateFile( std::string const& file_path); ...@@ -49,11 +49,17 @@ void truncateFile( std::string const& file_path);
/** /**
* Extracts basename from given pathname with extension. * 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); std::string extractBaseName(std::string const& pathname);
/** /**
* Extracts basename from given pathname without its extension. * Extracts basename from given pathname without its extension.
*
* Same as extractBaseName(), but drops the file extension too.
*/ */
std::string extractBaseNameWithoutExtension(std::string const& pathname); std::string extractBaseNameWithoutExtension(std::string const& pathname);
...@@ -70,12 +76,15 @@ std::string getFileExtension(std::string const& filename); ...@@ -70,12 +76,15 @@ std::string getFileExtension(std::string const& filename);
bool hasFileExtension(std::string const& extension, 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); std::string copyPathToFileName(const std::string &file_name, const std::string &source);
/** /**
* Extracts the path of a pathname. * 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); std::string extractPath(std::string const& pathname);
} // end namespace BaseLib } // end namespace BaseLib
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment