diff --git a/src/shared/diagnostic/PrintLogger.cpp b/src/shared/diagnostic/PrintLogger.cpp index 6ede9aaf15168f7521bb259668088d01a029a099..0e23b4cee1c44c7f35e85799a769992aea8fe637 100644 --- a/src/shared/diagnostic/PrintLogger.cpp +++ b/src/shared/diagnostic/PrintLogger.cpp @@ -48,21 +48,13 @@ static string getLevelString(uint8_t level) static string truncateFileName(const string& name, int depth = 0) { - char sep = '/'; - - // 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); - } + // Find the first separator + auto start = name.find_last_of("\\/"); // Now traverse the path until we reach the end or the required depth 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