Skip to content
Snippets Groups Projects
Commit 291baaf3 authored by Dmitri Naumov's avatar Dmitri Naumov Committed by Dmitrij Naumov
Browse files

Add findLastPathSeparator().

parent de46338b
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,11 @@ void truncateFile( std::string const& filename) ...@@ -59,6 +59,11 @@ void truncateFile( std::string const& filename)
ofs.close(); ofs.close();
} }
size_t findLastPathSeparator(std::string const& path)
{
return path.find_last_of("/\\");
}
std::string getFileNameFromPath(const std::string &str, bool with_extension) std::string getFileNameFromPath(const std::string &str, bool with_extension)
{ {
std::string::size_type beg1 = str.find_last_of('/'); std::string::size_type beg1 = str.find_last_of('/');
......
...@@ -21,6 +21,13 @@ ...@@ -21,6 +21,13 @@
namespace BaseLib namespace BaseLib
{ {
/** Finds the position of last file path separator.
* Checks for unix or windows file path separators in given path and returns the
* position of the last one or std::string::npos if no file path separator was
* found.
*/
size_t findLastPathSeparator(std::string const& path);
/** /**
* \brief Returns true if given file exists. From http://www.techbytes.ca/techbyte103.html * \brief Returns true if given file exists. From http://www.techbytes.ca/techbyte103.html
* *
......
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