mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-12 22:40:54 +01:00
1. Since swap module is disabled by default, swap detection is unnecessary in most cases. 2. On platform other than Linux, swap detection doesn't share code with memory. 3. Swap detection can be expensive. On Windows, it requires another WMI query which can lag heavily in some cases. Don't pay for you don't use.
24 lines
614 B
C++
24 lines
614 B
C++
extern "C" {
|
|
#include "swap.h"
|
|
}
|
|
#include "util/windows/wmi.hpp"
|
|
|
|
extern "C"
|
|
void ffDetectSwapImpl(FFMemoryStorage* swap)
|
|
{
|
|
FFWmiQuery query(L"SELECT AllocatedBaseSize, CurrentUsage FROM Win32_PageFileUsage", &swap->error);
|
|
if(!query)
|
|
return;
|
|
|
|
if(FFWmiRecord record = query.next())
|
|
{
|
|
//MB
|
|
record.getUnsigned(L"AllocatedBaseSize", &swap->bytesTotal);
|
|
record.getUnsigned(L"CurrentUsage", &swap->bytesUsed);
|
|
swap->bytesTotal *= 1024 * 1024;
|
|
swap->bytesUsed *= 1024 * 1024;
|
|
}
|
|
else
|
|
ffStrbufInitS(&swap->error, "No Wmi result returned");
|
|
}
|