Add Windows support.

This commit is contained in:
david 2020-07-04 19:43:08 +01:00
parent ee51f3ee09
commit 683ba5447f
37 changed files with 477 additions and 113 deletions

View file

@ -25,14 +25,14 @@ public:
}
}
static int ToInt(char* buffer, unsigned size, bool reverse = true)
static int ToInt(char* buffer, const unsigned size, bool reverse = true)
{
int result;
if(reverse)
{
char reversed[size];
ReverseBuffer(buffer, reversed, size);
std::memcpy(&result, reversed, sizeof(int));
std::string reversed;
ReverseBuffer(buffer, reversed.data(), size);
std::memcpy(&result, reversed.data(), sizeof(int));
}
else
{

View file

@ -1,3 +1,14 @@
list(APPEND core_HEADERS
Event.h
Color.h
CommandLineArgs.h
loggers/FileLogger.h
file_utilities/BinaryFile.h
file_utilities/File.h
file_utilities/FileFormats.h
StringUtils.h
http/HttpResponse.h)
list(APPEND core_LIB_INCLUDES
Event.cpp
Color.cpp
@ -10,10 +21,12 @@ list(APPEND core_LIB_INCLUDES
http/HttpResponse.cpp)
# add the executable
add_library(core SHARED ${core_LIB_INCLUDES})
add_library(core SHARED ${core_LIB_INCLUDES} ${core_HEADERS})
target_include_directories(core PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/file_utilities"
"${CMAKE_CURRENT_SOURCE_DIR}/loggers"
)
)
set_target_properties( core PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
set_property(TARGET core PROPERTY FOLDER src)

View file

@ -13,7 +13,7 @@ File::File(std::filesystem::path path)
std::string File::GetExtension() const
{
return mFullPath.extension();
return mFullPath.extension().string();
}
void File::SetAccessMode(AccessMode mode)

View file

@ -21,7 +21,7 @@ void HttpResponse::SetBody(const std::string& body)
unsigned HttpResponse::GetBodyLength()
{
return mBody.length();
return unsigned(mBody.length());
}
std::string HttpResponse::GetHeaderString()

View file

@ -1,5 +1,5 @@
#include "FileLogger.h"
#include <ctime>
#include <time.h>
#include <iomanip>
@ -37,5 +37,11 @@ void FileLogger::LogLine(const std::string& logType, const std::string& line, co
{
std::time_t t = std::time(nullptr);
const std::string cleanedFileName = fileName.substr(fileName.find_last_of("/\\") + 1);
mFileStream << logType << "|" << std::put_time(std::gmtime(&t), "%T") << "|" << cleanedFileName << "::" << functionName << "::" << lineNumber << "|" << line << std::endl;
std::tm time_buf = { 0 };
#ifdef WIN32
gmtime_s(&time_buf, &t);
#else
std::gmtime_s(&t, &time_buf);
#endif
mFileStream << logType << "|" << std::put_time(&time_buf, "%T") << "|" << cleanedFileName << "::" << functionName << "::" << lineNumber << "|" << line << std::endl;
}