Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
W32Compat.cpp
1 // must be first:
2 //#include "precompiled.h"
3 
4 /*
5 This file is part of the BIAS library (Basic ImageAlgorithmS).
6 
7 Copyright (C) 2003-2009 (see file CONTACT for details)
8  Multimediale Systeme der Informationsverarbeitung
9  Institut fuer Informatik
10  Christian-Albrechts-Universitaet Kiel
11 
12 
13 BIAS is free software; you can redistribute it and/or modify
14 it under the terms of the GNU Lesser General Public License as published by
15 the Free Software Foundation; either version 2.1 of the License, or
16 (at your option) any later version.
17 
18 BIAS is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU Lesser General Public License for more details.
22 
23 You should have received a copy of the GNU Lesser General Public License
24 along with BIAS; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 */
27 
28 #ifdef WIN32
29 
30 #include "W32Compat.hh"
31 #include <windows.h>
32 #include <time.h>
33 #include <math.h>
34 
35 // for mkdir:
36 #include <direct.h>
37 
38 
39 
40 int gettimeofday(struct timeval *tv, struct timezone *tz)
41 {
42  FILETIME ft;
43  LARGE_INTEGER li;
44  __int64 t;
45  static int tzflag;
46 
47  if (tv)
48  {
49  GetSystemTimeAsFileTime(&ft);
50  li.LowPart = ft.dwLowDateTime;
51  li.HighPart = ft.dwHighDateTime;
52  t = li.QuadPart; /* In 100-nanosecond intervals */
53  t -= EPOCHFILETIME; /* Offset to the Epoch time */
54  t /= 10; /* In microseconds */
55  tv->tv_sec = (long)(t / 1000000);
56  tv->tv_usec = (long)(t % 1000000);
57  }
58 
59  if (tz)
60  {
61  if (!tzflag)
62  {
63  _tzset();
64  tzflag++;
65  }
66  tz->tz_minuteswest = _timezone / 60;
67  tz->tz_dsttime = _daylight;
68  }
69  return 0;
70 }
71 
72 
73 int mkdir(const char *dirname, int /*mode_IsIgnored*/ )
74 {
75  //return mkdir(dirname);
76  return _mkdir(dirname); // VS 8 from direct.h
77 }
78 
79 double copysign(double x, double y)
80 {
81  return (y>=0.0)?(fabs(x)):(-fabs(x));
82 }
83 
84 #endif // Win32