From a9987ab57042ce755261492d93cb54d9ff10fc35 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 12 Jul 2009 22:52:13 +0000 Subject: Fix a few compiler errors reported correctly my MSVC 9.0. Fix libtests test suites to pass on Windows, mostly by dealing with ascii vs. binary and NL vs. CRNL change ($td->NORMALIZE_NEWLINES). Convert some test suites to use fread instead of read. PCRE.hh: define PCRE_STATIC if on Windows. Provide cross-platform function for getting current time instead of using time(0). git-svn-id: svn+q:///qpdf/trunk@678 71b93d88-0707-0410-a8cf-f5a4172ac649 --- libqpdf/QUtil.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'libqpdf/QUtil.cc') diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index 0ffc6e26..3ac467d4 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -141,6 +141,32 @@ QUtil::get_env(std::string const& var, std::string* value) #endif } +time_t +QUtil::get_current_time() +{ +#ifdef _WIN32 + // The procedure to get local time at this resolution comes from + // the Microsoft documentation. It says to convert a SYSTEMTIME + // to a FILETIME, and to copy the FILETIME to a ULARGE_INTEGER. + // The resulting number is the number of 100-nanosecond intervals + // between January 1, 1601 and now. POSIX threads wants a time + // based on January 1, 1970, so we adjust by subtracting the + // number of seconds in that time period from the result we get + // here. + SYSTEMTIME sysnow; + GetSystemTime(&sysnow); + FILETIME filenow; + SystemTimeToFileTime(&sysnow, &filenow); + ULARGE_INTEGER uinow; + uinow.LowPart = filenow.dwLowDateTime; + uinow.HighPart = filenow.dwHighDateTime; + ULONGLONG now = uinow.QuadPart; + return ((now / 10000000LL) - 11644473600LL); +#else + return time(0); +#endif +} + std::string QUtil::toUTF8(unsigned long uval) { -- cgit v1.2.3-54-g00ecf