blob: f3e1065b74446c3ee58d2c5dfc3ee5f282748d6b (
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
|
#include "platform.hpp"
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
static bool GetUserWritableDir(string & outDir)
{
char * path = ::getenv("HOME");
if (path)
{
outDir = path;
outDir += "." LOCALAPPDATA_DIR "/";
::mkdir(outDir.c_str(), 0755);
return true;
}
return false;
}
/// @return full path including binary itself
static bool GetPathToBinary(string & outPath)
{
char path[4096] = {0};
if (0 < ::readlink("/proc/self/exe", path, ARRAY_SIZE(path)))
{
outPath = path;
return true;
}
return false;
}
int Platform::CpuCores() const
{
long numCPU = sysconf(_SC_NPROCESSORS_ONLN);
if (numCPU >= 1)
return static_cast<int>(numCPU);
return 1;
}
string Platform::UniqueClientId() const
{
return "@TODO";
}
|