diff options
author | Petr Mrázek <peterix@users.noreply.github.com> | 2021-12-30 20:00:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-30 20:00:45 +0100 |
commit | 3efcccf334e28d03605dd0597f53f900105cf04b (patch) | |
tree | ecafd89c7eb90d04f428c907da86c7d6b134c166 /libraries/systeminfo/src/sys_unix.cpp | |
parent | 5e909a4e852a5bf3ba9dec9081b4839773bfc0ce (diff) | |
parent | f42c3a953c15b01632131435e4885f9acc3b1f1a (diff) | |
download | PrismLauncher-3efcccf334e28d03605dd0597f53f900105cf04b.tar.gz PrismLauncher-3efcccf334e28d03605dd0597f53f900105cf04b.tar.bz2 PrismLauncher-3efcccf334e28d03605dd0597f53f900105cf04b.zip |
Merge pull request #4345 from graemeg/freebsd-support
Adds FreeBSD support to MultiMC
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 } |