|
|
@ -198,12 +198,12 @@ inline size_t filesize(FILE *f)
|
|
|
|
throw spdlog_ex("Failed getting file size. fd is null");
|
|
|
|
throw spdlog_ex("Failed getting file size. fd is null");
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
int fd = _fileno(f);
|
|
|
|
int fd = _fileno(f);
|
|
|
|
#if _WIN64 //64 bits
|
|
|
|
#if _WIN64 //64 bits
|
|
|
|
struct _stat64 st;
|
|
|
|
struct _stat64 st;
|
|
|
|
if (_fstat64(fd, &st) == 0)
|
|
|
|
if (_fstat64(fd, &st) == 0)
|
|
|
|
return st.st_size;
|
|
|
|
return st.st_size;
|
|
|
|
|
|
|
|
|
|
|
|
#else //windows 32 bits
|
|
|
|
#else //windows 32 bits
|
|
|
|
struct _stat st;
|
|
|
|
struct _stat st;
|
|
|
|
if (_fstat(fd, &st) == 0)
|
|
|
|
if (_fstat(fd, &st) == 0)
|
|
|
|
return st.st_size;
|
|
|
|
return st.st_size;
|
|
|
@ -216,7 +216,7 @@ inline size_t filesize(FILE *f)
|
|
|
|
struct stat64 st;
|
|
|
|
struct stat64 st;
|
|
|
|
if (fstat64(fd, &st) == 0)
|
|
|
|
if (fstat64(fd, &st) == 0)
|
|
|
|
return st.st_size;
|
|
|
|
return st.st_size;
|
|
|
|
#else // unix 32 bits or osx
|
|
|
|
#else // unix 32 bits or osx
|
|
|
|
struct stat st;
|
|
|
|
struct stat st;
|
|
|
|
if (fstat(fd, &st) == 0)
|
|
|
|
if (fstat(fd, &st) == 0)
|
|
|
|
return st.st_size;
|
|
|
|
return st.st_size;
|
|
|
@ -250,7 +250,42 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
|
|
|
|
offset -= tzinfo.StandardBias;
|
|
|
|
offset -= tzinfo.StandardBias;
|
|
|
|
return offset;
|
|
|
|
return offset;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
return static_cast<int>(tm.tm_gmtoff / 60);
|
|
|
|
long int offset_seconds;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(sun) || defined(__sun)
|
|
|
|
|
|
|
|
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
|
|
|
|
|
|
|
|
struct helper {
|
|
|
|
|
|
|
|
static long int calculate_gmt_offset(const std::tm & localtm = details::os::localtime(), const std::tm & gmtm = details::os::gmtime()) {
|
|
|
|
|
|
|
|
int local_year = localtm.tm_year + (1900 - 1);
|
|
|
|
|
|
|
|
int gmt_year = gmtm.tm_year + (1900 - 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long int days = (
|
|
|
|
|
|
|
|
// difference in day of year
|
|
|
|
|
|
|
|
localtm.tm_yday - gmtm.tm_yday
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// + intervening leap days
|
|
|
|
|
|
|
|
+ ((local_year >> 2) - (gmt_year >> 2))
|
|
|
|
|
|
|
|
- (local_year / 100 - gmt_year / 100)
|
|
|
|
|
|
|
|
+ ((local_year / 100 >> 2) - (gmt_year / 100 >> 2))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// + difference in years * 365 */
|
|
|
|
|
|
|
|
+ (long int)(local_year - gmt_year) * 365
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long int hours = (24 * days) + (localtm.tm_hour - gmtm.tm_hour);
|
|
|
|
|
|
|
|
long int mins = (60 * hours) + (localtm.tm_min - gmtm.tm_min);
|
|
|
|
|
|
|
|
long int secs = (60 * mins) + (localtm.tm_sec - gmtm.tm_sec);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return secs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
offset_seconds = helper::calculate_gmt_offset(tm);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
offset_seconds = tm.tm_gmtoff;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return static_cast<int>(offset_seconds / 60);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -269,7 +304,7 @@ inline size_t thread_id()
|
|
|
|
long tid;
|
|
|
|
long tid;
|
|
|
|
thr_self(&tid);
|
|
|
|
thr_self(&tid);
|
|
|
|
return static_cast<size_t>(tid);
|
|
|
|
return static_cast<size_t>(tid);
|
|
|
|
#else //Default to standard C++11 (OSX and other Unix)
|
|
|
|
#else //Default to standard C++11 (OSX and other Unix)
|
|
|
|
return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
|
|
|
|
return static_cast<size_t>(std::hash<std::thread::id>()(std::this_thread::get_id()));
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|