mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-09 11:33:25 -08:00
24 lines
692 B
C++
24 lines
692 B
C++
#ifndef COCKATRICE_SYSTEM_MEMORY_QUERIER_H
|
|
#define COCKATRICE_SYSTEM_MEMORY_QUERIER_H
|
|
|
|
#include <QtGlobal>
|
|
|
|
class SystemMemoryQuerier
|
|
{
|
|
public:
|
|
static qulonglong totalMemoryBytes();
|
|
|
|
static bool hasAtLeastGiB(int gib)
|
|
{
|
|
const qulonglong total = totalMemoryBytes();
|
|
// 0 means the amount could not be determined (unsupported platform or failed query).
|
|
// Treat it as unknown and skip the check instead of misreading it as low memory.
|
|
if (total == 0) {
|
|
return true;
|
|
}
|
|
const qulonglong GiB = 1024ull * 1024ull * 1024ull;
|
|
return total >= (qulonglong)gib * GiB;
|
|
}
|
|
};
|
|
|
|
#endif // COCKATRICE_SYSTEM_MEMORY_QUERIER_H
|