From 5076c75b079fe02c843ca85dc20821e468b2d7b8 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 12 Aug 2013 16:57:34 -0400 Subject: More Windows port work. --- node/Utils.hpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'node/Utils.hpp') diff --git a/node/Utils.hpp b/node/Utils.hpp index 8f5e7006..00564ae6 100644 --- a/node/Utils.hpp +++ b/node/Utils.hpp @@ -32,8 +32,6 @@ #include #include #include -#include -#include #include #include @@ -44,9 +42,12 @@ #include "../ext/lz4/lz4hc.h" #ifdef __WINDOWS__ -#include +#include +#include #else #include +#include +#include #endif #include "Constants.hpp" @@ -74,7 +75,7 @@ public: throw() { #ifdef __WINDOWS__ - foo; + DeleteFile(path); #else return (unlink(path) == 0); #endif @@ -342,9 +343,20 @@ public: static inline uint64_t now() throw() { +#ifdef __WINDOWS__ + FILETIME ft; + SYSTEMTIME st; + ULARGE_INTEGER tmp; + GetSystemTime(&st); + SystemTimeToFileTime(&st,&ft); + tmp.LowPart = ft.dwLowDateTime; + tmp.HighPart = ft.dwHighDateTime; + return ( ((tmp.QuadPart - 116444736000000000ULL) / 10000L) + st.wMilliseconds ); +#else struct timeval tv; gettimeofday(&tv,(struct timezone *)0); return ( (1000ULL * (uint64_t)tv.tv_sec) + (uint64_t)(tv.tv_usec / 1000) ); +#endif }; /** @@ -353,9 +365,20 @@ public: static inline double nowf() throw() { +#ifdef __WINDOWS__ + FILETIME ft; + SYSTEMTIME st; + ULARGE_INTEGER tmp; + GetSystemTime(&st); + SystemTimeToFileTime(&st,&ft); + tmp.LowPart = ft.dwLowDateTime; + tmp.HighPart = ft.dwHighDateTime; + return (((double)(tmp.QuadPart - 116444736000000000ULL)) / 10000000.0); +#else struct timeval tv; gettimeofday(&tv,(struct timezone *)0); return ( ((double)tv.tv_sec) + (((double)tv.tv_usec) / 1000000.0) ); +#endif } /** -- cgit v1.2.3