Skip to content
Snippets Groups Projects
Commit d9a66e59 authored by Davide Mor's avatar Davide Mor
Browse files

[PrintLogger] Replaced rfind with find_last_of

parent a7de7182
No related branches found
No related tags found
No related merge requests found
...@@ -48,21 +48,13 @@ static string getLevelString(uint8_t level) ...@@ -48,21 +48,13 @@ static string getLevelString(uint8_t level)
static string truncateFileName(const string& name, int depth = 0) static string truncateFileName(const string& name, int depth = 0)
{ {
char sep = '/'; // Find the first separator
auto start = name.find_last_of("\\/");
// Find the first separator if there is one
auto start = name.rfind(sep);
if (start == string::npos)
{
// Maybe we are on windows...
sep = '\\';
start = name.rfind(sep);
}
// Now traverse the path until we reach the end or the required depth // Now traverse the path until we reach the end or the required depth
for (int i = 0; i < depth && start != string::npos; i++) for (int i = 0; i < depth && start != string::npos; i++)
{ {
start = name.rfind(sep, start - 1); start = name.find_last_of("\\/", start - 1);
} }
// Truncate the path if needed // Truncate the path if needed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment