fix mingw build
This commit is contained in:
@@ -28,7 +28,8 @@ if (${PLATFORM} STREQUAL "Desktop")
|
||||
|
||||
if (WIN32)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
set(EXTRA_LIBS ws2_32)
|
||||
include_directories(misc/windows)
|
||||
set(EXTRA_LIBS ws2_32 winhttp)
|
||||
elseif(UNIX)
|
||||
find_library(pthread NAMES pthread)
|
||||
set(EXTRA_LIBS pthread m)
|
||||
|
||||
2
misc/windows/WinSock2.h
Normal file
2
misc/windows/WinSock2.h
Normal file
@@ -0,0 +1,2 @@
|
||||
// For mingw, cuz on linux it case-sensitive
|
||||
#include <winsock2.h>
|
||||
2
misc/windows/Ws2tcpip.h
Normal file
2
misc/windows/Ws2tcpip.h
Normal file
@@ -0,0 +1,2 @@
|
||||
// For mingw, cuz on linux it case-sensitive
|
||||
#include <ws2tcpip.h>
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
|
||||
virtual bool supportsTouchscreen() override { return true; }
|
||||
|
||||
virtual void hideCursor(bool hide) {
|
||||
virtual void hideCursor(bool hide) override {
|
||||
int isHide = hide ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_HIDDEN;
|
||||
glfwSetInputMode(window, GLFW_CURSOR, isHide);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
#include <errno.h>
|
||||
#include <platform/log.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#if defined(_WIN32)
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
OptionsFile::OptionsFile() {
|
||||
@@ -27,39 +28,44 @@ void OptionsFile::setOptionsPath(const std::string& path) {
|
||||
std::string OptionsFile::getOptionsPath() const {
|
||||
return settingsPath;
|
||||
}
|
||||
|
||||
void OptionsFile::save(const StringVector& settings) {
|
||||
FILE* pFile = fopen(settingsPath.c_str(), "w");
|
||||
if(pFile != NULL) {
|
||||
for(StringVector::const_iterator it = settings.begin(); it != settings.end(); ++it) {
|
||||
fprintf(pFile, "%s\n", it->c_str());
|
||||
}
|
||||
fclose(pFile);
|
||||
} else {
|
||||
if (errno != ENOENT)
|
||||
LOGI("OptionsFile::save failed to open '%s' for writing: %s", settingsPath.c_str(), strerror(errno));
|
||||
FILE* pFile = fopen(settingsPath.c_str(), "w");
|
||||
|
||||
// Ensure parent directory exists for safekeeping if path contains directories
|
||||
std::string dir = settingsPath;
|
||||
size_t fpos = dir.find_last_of("/\\");
|
||||
if (fpos != std::string::npos) {
|
||||
dir.resize(fpos);
|
||||
struct stat st;
|
||||
if (stat(dir.c_str(), &st) != 0) {
|
||||
// attempt recursive mkdir
|
||||
std::string toCreate;
|
||||
for (size_t i = 0; i <= dir.size(); ++i) {
|
||||
if (i == dir.size() || dir[i] == '/' || dir[i] == '\\') {
|
||||
if (!toCreate.empty()) {
|
||||
mkdir(toCreate.c_str(), 0755);
|
||||
}
|
||||
}
|
||||
if (i < dir.size())
|
||||
toCreate.push_back(dir[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!pFile && errno == ENOENT) {
|
||||
std::string dir = settingsPath;
|
||||
size_t fpos = dir.find_last_of("/\\");
|
||||
if (fpos != std::string::npos) {
|
||||
dir.resize(fpos);
|
||||
|
||||
std::string toCreate;
|
||||
for (size_t i = 0; i <= dir.size(); ++i) {
|
||||
if (i == dir.size() || dir[i] == '/' || dir[i] == '\\') {
|
||||
if (!toCreate.empty()) {
|
||||
#if defined(_WIN32)
|
||||
_mkdir(toCreate.c_str());
|
||||
#else
|
||||
mkdir(toCreate.c_str(), 0755);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (i < dir.size())
|
||||
toCreate.push_back(dir[i]);
|
||||
}
|
||||
}
|
||||
|
||||
pFile = fopen(settingsPath.c_str(), "w");
|
||||
}
|
||||
|
||||
if (!pFile) {
|
||||
LOGI("OptionsFile::save failed: %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& s : settings) {
|
||||
fprintf(pFile, "%s\n", s.c_str());
|
||||
}
|
||||
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <direct.h>
|
||||
#include <sys/stat.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -140,7 +140,9 @@ RakNet::TimeUS GetTimeUS_Windows( void )
|
||||
#if _MSC_VER >= 1400 && defined (_M_X64)
|
||||
GetProcessAffinityMask(mProc, (PDWORD_PTR)&mProcMask, (PDWORD_PTR)&mSysMask);
|
||||
#else
|
||||
#ifndef __MINGW32__
|
||||
GetProcessAffinityMask(mProc, &mProcMask, &mSysMask);
|
||||
#endif
|
||||
#endif
|
||||
mThread = GetCurrentThread();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user