Split Sutbstitutes into cpp and header to make it possible to use unity build

This commit is contained in:
Magne Sjaastad
2020-11-16 14:55:29 +01:00
parent 99742e8062
commit be23df1398
3 changed files with 39 additions and 26 deletions
+4
View File
@@ -63,6 +63,10 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
endif() endif()
endif() endif()
if(MSVC)
list(APPEND opm-common_SOURCES opm-common/cross-platform/windows/Substitutes.cpp )
endif(MSVC)
add_library(${PROJECT_NAME} add_library(${PROJECT_NAME}
STATIC STATIC
${opm_parser_source_files_long_path} ${opm_parser_source_files_long_path}
@@ -0,0 +1,31 @@
#ifdef _WIN32
#include "Substitutes.hpp"
int
fnmatch(const char* pattern, const char* string, int flags)
{
if (flags != 0) {
std::cerr << __FUNCTION__ << "Warning: flags other than 0 are not supported in Windows.";
}
wchar_t pszFile[1024];
wchar_t pszSpec[1024];
size_t outsize;
mbstowcs_s(&outsize, pszFile, string, strlen(string) + 1);
mbstowcs_s(&outsize, pszSpec, pattern, strlen(pattern) + 1);
return (!PathMatchSpecW(pszFile, pszSpec));
}
struct tm*
gmtime_r(const time_t* timer, struct tm* buf)
{
if (gmtime_s(buf, timer) == 0) {
return nullptr;
} else {
return buf;
}
}
#endif
@@ -1,4 +1,5 @@
#pragma once #pragma once
#ifdef _WIN32 #ifdef _WIN32
#include <Shlwapi.h> #include <Shlwapi.h>
@@ -15,31 +16,8 @@
#include <stddef.h> #include <stddef.h>
#include <time.h> #include <time.h>
int fnmatch(const char* pattern, const char* string, int flags) int fnmatch(const char* pattern, const char* string, int flags);
{
if (flags != 0) {
std::cerr << __FUNCTION__ << "Warning: flags other than 0 are not supported in Windows.";
}
wchar_t pszFile[1024];
wchar_t pszSpec[1024];
size_t outsize; struct tm* gmtime_r(const time_t* timer, struct tm* buf);
mbstowcs_s(&outsize, pszFile, string, strlen(string) + 1);
mbstowcs_s(&outsize, pszSpec, pattern, strlen(pattern) + 1);
return (!PathMatchSpecW(pszFile, pszSpec));
}
struct tm* gmtime_r(const time_t* timer, struct tm* buf)
{
if (gmtime_s(buf, timer) == 0)
{
return nullptr;
}
else
{
return buf;
}
}
#endif #endif