src: replaced some usages of string by wstring in filepath
This commit is contained in:
@@ -370,8 +370,6 @@ add_files(
|
||||
utility/logging/FileLogger.h
|
||||
utility/logging/Logger.cpp
|
||||
utility/logging/Logger.h
|
||||
utility/logging/LoggerUtility.cpp
|
||||
utility/logging/LoggerUtility.h
|
||||
utility/logging/logging.h
|
||||
utility/logging/LogManager.cpp
|
||||
utility/logging/LogManager.h
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "data/indexer/IndexerCommand.h"
|
||||
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
IndexerCommand::IndexerCommand(
|
||||
const FilePath& sourceFilePath, const std::set<FilePath>& indexedPaths, const std::set<FilePath>& excludedPaths
|
||||
)
|
||||
@@ -15,16 +17,16 @@ IndexerCommand::~IndexerCommand()
|
||||
|
||||
size_t IndexerCommand::getByteSize(size_t stringSize) const
|
||||
{
|
||||
size_t size = m_sourceFilePath.str().size();
|
||||
size_t size = utility::encodeToUtf8(m_sourceFilePath.wstr()).size();
|
||||
|
||||
for (const FilePath& path: m_indexedPaths)
|
||||
{
|
||||
size += stringSize + path.str().size();
|
||||
size += stringSize + utility::encodeToUtf8(path.wstr()).size();
|
||||
}
|
||||
|
||||
for (const FilePath& path : m_excludedPaths)
|
||||
{
|
||||
size += stringSize + path.str().size();
|
||||
size += stringSize + utility::encodeToUtf8(path.wstr()).size();
|
||||
}
|
||||
|
||||
return size;
|
||||
|
||||
@@ -1885,7 +1885,7 @@ TooltipInfo PersistentStorage::getTooltipInfoForSourceLocationIdsAndLocalSymbolI
|
||||
const NameHierarchy nameHierarchy = NameHierarchy::deserialize(node.serializedName);
|
||||
snippet.code = codec.encode(nameHierarchy.getQualifiedName());
|
||||
snippet.locationFile = std::make_shared<SourceLocationFile>(
|
||||
FilePath(nameHierarchy.getDelimiter() == NAME_DELIMITER_JAVA ? "main.java" : "main.cpp"), true, true);
|
||||
FilePath(nameHierarchy.getDelimiter() == NAME_DELIMITER_JAVA ? L"main.java" : L"main.cpp"), true, true);
|
||||
|
||||
snippet.locationFile->addSourceLocation(
|
||||
LOCATION_TOKEN, 0, std::vector<Id>(1, node.id), 1, 1, 1, snippet.code.size());
|
||||
@@ -2645,7 +2645,7 @@ void PersistentStorage::buildMemberEdgeIdOrderMap()
|
||||
intToLocationType(location.type),
|
||||
location.id,
|
||||
std::vector<Id>(),
|
||||
FilePath(std::to_string(location.fileNodeId)),
|
||||
FilePath(std::to_wstring(location.fileNodeId)),
|
||||
location.startLine,
|
||||
location.startCol,
|
||||
location.endLine,
|
||||
|
||||
@@ -2,14 +2,43 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <ctime>
|
||||
#include <cstdio>
|
||||
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
std::wstring FileLogger::generateDatedFileName(const std::wstring& prefix, const std::wstring& suffix)
|
||||
{
|
||||
time_t time;
|
||||
std::time(&time);
|
||||
tm t = *std::localtime(&time);
|
||||
|
||||
std::wstringstream filename;
|
||||
if (!prefix.empty())
|
||||
{
|
||||
filename << prefix;
|
||||
filename << L"_";
|
||||
}
|
||||
filename << t.tm_year + 1900 << L"-";
|
||||
filename << (t.tm_mon < 9 ? L"0" : L"") << t.tm_mon + 1 << L"-";
|
||||
filename << (t.tm_mday < 10 ? L"0" : L"") << t.tm_mday << L"_";
|
||||
filename << (t.tm_hour < 10 ? L"0" : L"") << t.tm_hour << L"-";
|
||||
filename << (t.tm_min < 10 ? L"0" : L"") << t.tm_min << L"-";
|
||||
filename << (t.tm_sec < 10 ? L"0" : L"") << t.tm_sec;
|
||||
|
||||
if (!suffix.empty())
|
||||
{
|
||||
filename << L"_";
|
||||
filename << suffix;
|
||||
}
|
||||
|
||||
return filename.str();
|
||||
}
|
||||
|
||||
FileLogger::FileLogger()
|
||||
: Logger("FileLogger")
|
||||
, m_logFileName("log")
|
||||
, m_logFileName(L"log")
|
||||
, m_logDirectory(L"user/log/")
|
||||
, m_maxLogLineCount(0)
|
||||
, m_maxLogFileCount(0)
|
||||
@@ -31,7 +60,7 @@ FilePath FileLogger::getLogFilePath() const
|
||||
void FileLogger::setLogFilePath(const FilePath& filePath)
|
||||
{
|
||||
m_currentLogFilePath = filePath;
|
||||
m_logFileName = "";
|
||||
m_logFileName = L"";
|
||||
}
|
||||
|
||||
void FileLogger::setLogDirectory(const FilePath& filePath)
|
||||
@@ -40,7 +69,7 @@ void FileLogger::setLogDirectory(const FilePath& filePath)
|
||||
FileSystem::createDirectory(m_logDirectory);
|
||||
}
|
||||
|
||||
void FileLogger::setFileName(const std::string& fileName)
|
||||
void FileLogger::setFileName(const std::wstring& fileName)
|
||||
{
|
||||
if (fileName != m_logFileName)
|
||||
{
|
||||
@@ -78,17 +107,17 @@ void FileLogger::setMaxLogFileCount(unsigned int fileCount)
|
||||
|
||||
void FileLogger::updateLogFileName()
|
||||
{
|
||||
if (!m_logFileName.size())
|
||||
if (m_logFileName.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool fileChanged = false;
|
||||
|
||||
std::string currentLogFilePath = m_logDirectory.str() + m_logFileName;
|
||||
std::wstring currentLogFilePath = m_logDirectory.wstr() + m_logFileName;
|
||||
if (m_maxLogFileCount > 0)
|
||||
{
|
||||
currentLogFilePath += "_";
|
||||
currentLogFilePath += L"_";
|
||||
if (m_currentLogLineCount >= m_maxLogLineCount)
|
||||
{
|
||||
m_currentLogLineCount = 0;
|
||||
@@ -100,10 +129,10 @@ void FileLogger::updateLogFileName()
|
||||
}
|
||||
fileChanged = true;
|
||||
}
|
||||
currentLogFilePath += std::to_string(m_currentLogFileCount);
|
||||
currentLogFilePath += std::to_wstring(m_currentLogFileCount);
|
||||
|
||||
}
|
||||
currentLogFilePath += ".txt";
|
||||
currentLogFilePath += L".txt";
|
||||
|
||||
m_currentLogFilePath = FilePath(currentLogFilePath);
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
class FileLogger: public Logger
|
||||
{
|
||||
public:
|
||||
static std::wstring generateDatedFileName(const std::wstring& prefix = L"", const std::wstring& suffix = L"");
|
||||
|
||||
FileLogger();
|
||||
virtual ~FileLogger();
|
||||
|
||||
@@ -17,7 +19,7 @@ public:
|
||||
void setLogFilePath(const FilePath& filePath);
|
||||
|
||||
void setLogDirectory(const FilePath& filePath);
|
||||
void setFileName(const std::string& fileName);
|
||||
void setFileName(const std::wstring& fileName);
|
||||
void setMaxLogLineCount(unsigned int logCount);
|
||||
|
||||
// setting the max log file count to 0 will disable ringlogging
|
||||
@@ -31,7 +33,7 @@ private:
|
||||
void logMessage(const std::string& type, const LogMessage& message);
|
||||
void updateLogFileName();
|
||||
|
||||
std::string m_logFileName;
|
||||
std::wstring m_logFileName;
|
||||
FilePath m_logDirectory;
|
||||
FilePath m_currentLogFilePath;
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
#include "LoggerUtility.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <ctime>
|
||||
|
||||
std::string LoggerUtility::generateDatedFileName(const std::string& prefix, const std::string& suffix)
|
||||
{
|
||||
time_t time;
|
||||
std::time(&time);
|
||||
tm t = *std::localtime(&time);
|
||||
|
||||
std::stringstream filename;
|
||||
if (prefix.length() > 0)
|
||||
{
|
||||
filename << prefix;
|
||||
filename << "_";
|
||||
}
|
||||
filename << t.tm_year + 1900 << "-";
|
||||
filename << (t.tm_mon < 9 ? "0" : "") << t.tm_mon + 1 << "-";
|
||||
filename << (t.tm_mday < 10 ? "0" : "") << t.tm_mday << "_";
|
||||
filename << (t.tm_hour < 10 ? "0" : "") << t.tm_hour << "-";
|
||||
filename << (t.tm_min < 10 ? "0" : "") << t.tm_min << "-";
|
||||
filename << (t.tm_sec < 10 ? "0" : "") << t.tm_sec;
|
||||
|
||||
if (suffix.length() > 0)
|
||||
{
|
||||
filename << "_";
|
||||
filename << suffix;
|
||||
}
|
||||
|
||||
return filename.str();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef LOGGER_UTILITY_H
|
||||
#define LOGGER_UTILITY_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class LoggerUtility
|
||||
{
|
||||
public:
|
||||
static std::string generateDatedFileName(const std::string& prefix = "", const std::string& suffix = "");
|
||||
};
|
||||
|
||||
#endif // LOGGER_UTILITY_H
|
||||
Reference in New Issue
Block a user