From d6b9bf5525a12ab96d16785c6c72b863f519a9ab Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Sun, 2 Oct 2011 01:40:11 +0300 Subject: [ios][qt] Platform refactoring --- platform/platform_linux.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 platform/platform_linux.cpp (limited to 'platform/platform_linux.cpp') 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 +#include +#include + +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(numCPU); + return 1; +} + +string Platform::UniqueClientId() const +{ + return "@TODO"; +} -- cgit v1.2.3