Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 9957408e069b55bf266574b3b70494c8d0d360ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
   sys/sys.cc
   This file is part of the Osirion project and is distributed under
   the terms of the GNU General Public License version 2
*/

// project headers
#include "sys/sys.h"

// system headers
#ifdef _WIN32

#include <dlfcn.h>

#else

#include <unistd.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>

#endif
#include <stdlib.h>

namespace sys {

bool mkdir(const char *path)
{
#ifdef _WIN32
	::mkdir(path);
	// FIXME check return value
	return true;
#else
	return (::mkdir(path, 0777) == 0);
#endif
}

void signal(int signum, signalfunc handler)
{
#ifndef _WIN32
	struct sigaction sa;

	sa.sa_handler = handler;
	sa.sa_flags = 0;

	::sigaction(signum, &sa, 0);
#endif
}

unsigned long time() 
{
#ifndef _WIN32
	struct ::tm localtime;
	time_t epochtime = ::time(0);
	::localtime_r(&epochtime, &localtime);
	return ((unsigned long) (localtime.tm_sec + localtime.tm_min*60 + localtime.tm_hour*3600));
#else
	retrun 0;
#endif
}

void sleep(float seconds)
{
#ifndef _WIN32
	::usleep((useconds_t) seconds * (useconds_t) 1000000.0 );
#endif
}

void quit(int status) {
	::exit(status);
}

}