diff options
Diffstat (limited to 'src/sys/sys.cc')
-rw-r--r-- | src/sys/sys.cc | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/sys/sys.cc b/src/sys/sys.cc index f99d533..f4e915d 100644 --- a/src/sys/sys.cc +++ b/src/sys/sys.cc @@ -37,11 +37,11 @@ bool file_exists(const std::string &filename) #ifdef _WIN32 struct ::_stat path_stat; memset(&path_stat, 0, sizeof(struct ::_stat)); - + if (::_stat(filename.c_str(), &path_stat) != 0) { return false; } - + if (path_stat.st_mode & _S_IFDIR) { return false; } @@ -49,15 +49,15 @@ bool file_exists(const std::string &filename) #else struct stat path_stat; memset(&path_stat, 0, sizeof(path_stat)); - + if (stat(filename.c_str(), &path_stat) != 0) { return false; } - + if (path_stat.st_mode & S_IFDIR) { return false; } - + return true; #endif } @@ -68,11 +68,11 @@ bool directory_exists(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; } @@ -80,15 +80,15 @@ bool directory_exists(const std::string &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; } - + return false; #endif } @@ -100,13 +100,13 @@ void mkdir(const std::string &path) for (size_t i = 0; i < p.size(); i++) if (p[i] == '/') p[i] = '\\'; if (p.size() && (p[p.size()-1] == '\\')) - p.erase(p.size() -1, 1); - + p.erase(p.size() - 1, 1); + if (_mkdir(p.c_str()) != 0) { con_warn << "Could not create directory '" << p << "'" << std::endl; } #else - + ::mkdir(path.c_str(), 0777); #endif } @@ -115,12 +115,12 @@ void signal(int signum, signalfunc handler) { #ifndef _WIN32 struct sigaction sa; - + sa.sa_sigaction = 0; - memset(&sa.sa_mask, 0 ,sizeof(sigset_t)); + memset(&sa.sa_mask, 0 , sizeof(sigset_t)); sa.sa_flags = 0; sa.sa_handler = handler; - + ::sigaction(signum, &sa, 0); #endif } @@ -130,7 +130,7 @@ void signal(int signum, signalfunc handler) POSIX: struct tm { - int tm_sec; // seconds + int tm_sec; // seconds int tm_min; // minutes int tm_hour; // hours int tm_mday; // day of the month @@ -140,7 +140,7 @@ POSIX: int tm_yday; // day in the year int tm_isdst; // daylight saving time }; - + WIN32: typedef struct _SYSTEMTIME { @@ -153,7 +153,7 @@ WIN32: WORD wSecond; WORD wMilliseconds; } SYSTEMTIME, *PSYSTEMTIME; - + */ unsigned long time() @@ -166,7 +166,7 @@ unsigned long time() #else SYSTEMTIME localtime; ::GetLocalTime(&localtime); - + return ((unsigned long)(localtime.wSecond + localtime.wMinute*60 + localtime.wHour*3600)); #endif } @@ -188,7 +188,7 @@ void get_datetime(int &year, int & month, int & day, int & hours, int & minutes) ::localtime_r(&epochtime, &localtime); year = localtime.tm_year + 1900; - month = localtime.tm_mon +1; + month = localtime.tm_mon + 1; day = localtime.tm_mday; hours = localtime.tm_hour; @@ -196,7 +196,7 @@ void get_datetime(int &year, int & month, int & day, int & hours, int & minutes) #else SYSTEMTIME localtime; ::GetLocalTime(&localtime); - + year = localtime.wYear; month = localtime.wMonth; day = localtime.wDay; |