From 59e67bb00c1c6563530fc910bcda51015f9cbc3e Mon Sep 17 00:00:00 2001 From: koldo Date: Thu, 30 Apr 2015 09:13:06 +0000 Subject: [PATCH] Functions4U: Added tmGetTimeX git-svn-id: svn://ultimatepp.org/upp/trunk@8395 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/Functions4U/Functions4U.cpp | 18 ++++++++++++++++++ bazaar/Functions4U/Functions4U.h | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bazaar/Functions4U/Functions4U.cpp b/bazaar/Functions4U/Functions4U.cpp index a5eaf9afd..38cbc2d52 100644 --- a/bazaar/Functions4U/Functions4U.cpp +++ b/bazaar/Functions4U/Functions4U.cpp @@ -2535,4 +2535,22 @@ Image GetRect(const Image& orig, const Rect &r) { return ib; } + +double tmGetTimeX() { +#ifdef __linux__ + struct timeval t; + if(gettimeofday(&t, 0) != 0) + return Null; + return t.tv_sec + t.tv_usec/1E6; +#elif defined(_WIN32) || defined(WIN32) + LARGE_INTEGER clock; + LARGE_INTEGER freq; + if(!QueryPerformanceCounter(&clock) || !QueryPerformanceFrequency(&freq)) + return Null; + return double(clock.QuadPart)/freq.QuadPart; +#else + return double(time(0)); // Low resolution +#endif +} + END_UPP_NAMESPACE \ No newline at end of file diff --git a/bazaar/Functions4U/Functions4U.h b/bazaar/Functions4U/Functions4U.h index b839c7aae..cbbb1b985 100644 --- a/bazaar/Functions4U/Functions4U.h +++ b/bazaar/Functions4U/Functions4U.h @@ -73,7 +73,7 @@ bool IsReadOnly(const char *path, bool &usr, bool &grp, bool &oth); String LoadFile_Safe(const String fileName); String LoadFile(const char *fileName, off_t from, size_t len = 0); -int64 GetLength(const char *fileDirName); +int64 GetLength(const char *fileDirName); int64 GetDirectoryLength(const char *directoryName); /////////////////////////////// @@ -527,6 +527,8 @@ Color RandomColor(); Image GetRect(const Image& orig, const Rect &r); +double tmGetTimeX(); + class _NRFuse { public: _NRFuse(bool *_inside) {inside = _inside; failed = true;}