File: system.cpp

package info (click to toggle)
rafkill 1.2.2-3.3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 13,268 kB
  • sloc: cpp: 13,508; makefile: 64; sh: 14
file content (39 lines) | stat: -rw-r--r-- 615 bytes parent folder | download | duplicates (12)
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
#include "system.h"
#include <strings.h>
#include <string>

#ifdef WINDOWS
static const char * type(){
	return "WINBLOWS";
}

static std::string homeDir(){
	return std::string( "." );
}

#else
#include <sys/types.h>
#include <pwd.h>

static const char * type(){
	return "UNIX";
}

static std::string homeDir(){
	struct passwd * fields = getpwuid( getuid() );
	return std::string( fields->pw_dir );
}

#endif

bool System::onWindows(){
	return strcasecmp( type(), "WINBLOWS" ) == 0;
}

bool System::onUnix(){
	return strcasecmp( type(), "UNIX" ) == 0;
}

std::string System::getHomeDirectory(){
	return homeDir();
}