diff options
author | Alex Zolotarev <deathbaba@gmail.com> | 2011-10-02 02:40:11 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:24:55 +0300 |
commit | d6b9bf5525a12ab96d16785c6c72b863f519a9ab (patch) | |
tree | 34d417e39a83505d89ac672e7b9f37bfd0a4d96f /platform/platform_linux.cpp | |
parent | 0345b017ffee30c4504cbd91ba0d32be6fec826e (diff) |
[ios][qt] Platform refactoring
Diffstat (limited to 'platform/platform_linux.cpp')
-rw-r--r-- | platform/platform_linux.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/platform/platform_linux.cpp b/platform/platform_linux.cpp new file mode 100644 index 0000000000..f3e1065b74 --- /dev/null +++ b/platform/platform_linux.cpp @@ -0,0 +1,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"; +} |