Merge pull request #7378 from JosJuice/fix-reducing-log-paths
Fix reducing log paths when building with MSVC
This commit is contained in:
commit
8206e4862c
|
@ -2,8 +2,10 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <locale>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -67,8 +69,18 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char*
|
||||||
|
|
||||||
static size_t DeterminePathCutOffPoint()
|
static size_t DeterminePathCutOffPoint()
|
||||||
{
|
{
|
||||||
constexpr const char* pattern = DIR_SEP "Source" DIR_SEP "Core" DIR_SEP;
|
constexpr const char* pattern = "/source/core/";
|
||||||
size_t pos = std::string(__FILE__).find(pattern);
|
#ifdef _WIN32
|
||||||
|
constexpr const char* pattern2 = "\\source\\core\\";
|
||||||
|
#endif
|
||||||
|
std::string path = __FILE__;
|
||||||
|
std::transform(path.begin(), path.end(), path.begin(),
|
||||||
|
[](char c) { return std::tolower(c, std::locale::classic()); });
|
||||||
|
size_t pos = path.find(pattern);
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (pos == std::string::npos)
|
||||||
|
pos = path.find(pattern2);
|
||||||
|
#endif
|
||||||
if (pos != std::string::npos)
|
if (pos != std::string::npos)
|
||||||
return pos + strlen(pattern);
|
return pos + strlen(pattern);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue