/* 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 */ #ifdef _WIN32 #include #else #include #include #include #include #include #endif #include #include #include "sys/sys.h" namespace sys { void mkdir(std::string const &path) { #ifdef _WIN32 string p(path); for (size_t i = 0; i < p.lenght(); i++) if (p[i] == '/') p[i] = '\\'; ::mkdir(p.cstr()); #else ::mkdir(path.c_str(), 0777); #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 return 0; #endif } void sleep(float seconds) { #ifndef _WIN32 ::usleep((useconds_t) (seconds * 1000000.0f) ); #else Sleep((DWORD) (seconds*1000.0f)); #endif } void quit(int status) { ::exit(status); } }