Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/sys.cc')
-rw-r--r--src/sys/sys.cc32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/sys/sys.cc b/src/sys/sys.cc
index db2be4d..59ed11d 100644
--- a/src/sys/sys.cc
+++ b/src/sys/sys.cc
@@ -29,18 +29,19 @@
#include "sys/sys.h"
-namespace sys {
+namespace sys
+{
-bool isdirectory(std::string const &path)
+bool isdirectory(const std::string &path)
{
#ifdef _WIN32
struct ::_stat path_stat;
memset(&path_stat, 0, sizeof(struct ::_stat));
-
+
if (::_stat(path.c_str(), &path_stat) != 0) {
return false;
}
-
+
if (path_stat.st_mode & _S_IFDIR) {
return true;
}
@@ -48,11 +49,11 @@ bool isdirectory(std::string const &path)
#else
struct stat path_stat;
memset(&path_stat, 0, sizeof(path_stat));
-
+
if (stat(path.c_str(), &path_stat) != 0) {
return false;
}
-
+
if (path_stat.st_mode & S_IFDIR) {
return true;
}
@@ -61,7 +62,7 @@ bool isdirectory(std::string const &path)
#endif
}
-void mkdir(std::string const &path)
+void mkdir(const std::string &path)
{
#ifdef _WIN32
std::string p(path);
@@ -69,7 +70,7 @@ void mkdir(std::string const &path)
if (p[i] == '/') p[i] = '\\';
if (p.size() && (p[p.size()-1] == '\\'))
p.erase(p.size() -1, 1);
-
+
if (_mkdir(p.c_str()) != 0) {
con_warn << "Could not create directory '" << p << "'" << std::endl;
}
@@ -83,23 +84,23 @@ void signal(int signum, signalfunc handler)
{
#ifndef _WIN32
struct sigaction sa;
-
+
sa.sa_sigaction = 0;
memset(&sa.sa_mask, 0 ,sizeof(sigset_t));
sa.sa_flags = 0;
sa.sa_handler = handler;
-
+
::sigaction(signum, &sa, 0);
#endif
}
-unsigned long time()
+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));
+ return ((unsigned long)(localtime.tm_sec + localtime.tm_min*60 + localtime.tm_hour*3600));
#else
return 0;
#endif
@@ -108,13 +109,14 @@ unsigned long time()
void sleep(float seconds)
{
#ifndef _WIN32
- ::usleep((useconds_t) (seconds * 1000000.0f) );
+ ::usleep((useconds_t)(seconds * 1000000.0f));
#else
- Sleep((DWORD) (seconds*1000.0f));
+ Sleep((DWORD)(seconds*1000.0f));
#endif
}
-void quit(int status) {
+void quit(int status)
+{
::exit(status);
}