mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 01:51:38 +08:00
fopen_s adapter in details::os
This commit is contained in:
parent
f4d9c31a2f
commit
0c6a0d52d7
@ -1,4 +1,5 @@
|
||||
#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
|
||||
|
Loading…
Reference in New Issue
Block a user