diff options
author | swirl <roachh@protonmail.com> | 2021-12-31 14:27:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-31 14:27:21 -0500 |
commit | 541e2f0d8d56b1e808ac98b6cf5b3600f324f2fa (patch) | |
tree | 5a300af57c0207d38980319d54dc04218828aa1e /libraries/systeminfo/src/sys_unix.cpp | |
parent | 0c177b1086d69993e012ba1fbed1adf6bfe04144 (diff) | |
parent | fa98ed3ccd74cbf0228baf13851b6bb6d17d51a3 (diff) | |
download | PrismLauncher-541e2f0d8d56b1e808ac98b6cf5b3600f324f2fa.tar.gz PrismLauncher-541e2f0d8d56b1e808ac98b6cf5b3600f324f2fa.tar.bz2 PrismLauncher-541e2f0d8d56b1e808ac98b6cf5b3600f324f2fa.zip |
Merge pull request #8 from dada513/upstream_update
Diffstat (limited to 'libraries/systeminfo/src/sys_unix.cpp')
-rw-r--r-- | libraries/systeminfo/src/sys_unix.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libraries/systeminfo/src/sys_unix.cpp b/libraries/systeminfo/src/sys_unix.cpp index fb96c72c..b3098522 100644 --- a/libraries/systeminfo/src/sys_unix.cpp +++ b/libraries/systeminfo/src/sys_unix.cpp @@ -47,6 +47,7 @@ Sys::KernelInfo Sys::getKernelInfo() uint64_t Sys::getSystemRam() { std::string token; +#ifdef Q_OS_LINUX std::ifstream file("/proc/meminfo"); while(file >> token) { @@ -65,6 +66,19 @@ uint64_t Sys::getSystemRam() // ignore rest of the line file.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); } +#elif defined(Q_OS_FREEBSD) + char buff[512]; + FILE *fp = popen("sysctl hw.physmem", "r"); + if (fp != NULL) + { + while(fgets(buff, 512, fp) != NULL) + { + std::string str(buff); + uint64_t mem = std::stoull(str.substr(12, std::string::npos)); + return mem * 1024ull; + } + } +#endif return 0; // nothing found } |