Commit 0c6a0d52 authored by gabi's avatar gabi

fopen_s adapter in details::os

parent f4d9c31a
#pragma once
#include<string>
#include<cstdio>
#include<ctime>
......@@ -13,10 +14,11 @@ namespace os
inline std::tm localtime(const std::time_t &time_tt)
{
std::tm tm;
#ifdef _WIN32
std::tm tm;
localtime_s(&tm, &time_tt);
#else
std::tm tm;
localtime_r(&time_tt, &tm);
#endif
return tm;
......@@ -64,11 +66,22 @@ inline unsigned short eol_size()
#else
constexpr inline unsigned short eol_size()
{
return 1;
}
#endif
//fopen_s on non windows for writing
inline bool fopen_s(FILE** fp, const std::string& filename, const char* mode)
{
#ifdef _WIN32
return fopen_s(fp, filename, mode);
#else
*fp = fopen((filename.c_str()), mode);
return fp == nullptr;
#endif
}
} //os
} //details
} //c11log
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment