Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: a9958f4b4b83791ffe5032abe4a940b83e0d9b55 (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
75
76
77
78
/*
   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 {

void mkdir(const char *path)
{
#ifdef _WIN32
	::mkdir(path);
	return true;
#else
	::mkdir(path, 0777);
#endif
}

void mkdir(const std::string &path)
{
	mkdir(path.c_str());
}

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 * 1000000.0) );
#endif
}

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

}