[libcalamares] Some extra system-information functions

main
Adriaan de Groot 7 years ago
parent e83b4d33f8
commit 7a7e2b16cb

@ -232,7 +232,7 @@ System::targetEnvOutput( const QString& command,
QPair<quint64, float>
System::getTotalMemoryB()
System::getTotalMemoryB() const
{
#ifdef Q_OS_LINUX
struct sysinfo i;
@ -257,4 +257,33 @@ System::getTotalMemoryB()
}
QString
System::getCpuDescription() const
{
QString model;
#ifdef Q_OS_LINUX
QFile file("/proc/cpuinfo");
if ( file.open(QIODevice::ReadOnly | QIODevice::Text) )
while ( !file.atEnd() )
{
QByteArray line = file.readLine();
if ( line.startsWith( "model name" ) && (line.indexOf( ':' ) > 0) )
{
model = QString::fromLatin1( line.right(line.length() - line.indexOf( ':' ) ) );
break;
}
}
#elif defined( Q_OS_FREEBSD )
// This would use sysctl "hw.model", which has a string value
#endif
return model.simplified();
}
quint64
System::getTotalDiskB() const
{
return 0;
}
} // namespace

@ -112,7 +112,21 @@ public:
*
* @return size, guesstimate-factor
*/
DLLEXPORT QPair<quint64, float> getTotalMemoryB();
DLLEXPORT QPair<quint64, float> getTotalMemoryB() const;
/**
* @brief getCpuDescription returns a string describing the CPU.
*
* Returns the value of the "model name" line in /proc/cpuinfo.
*/
DLLEXPORT QString getCpuDescription() const;
/**
* @brief getTotalDiskB returns the total disk attached, in bytes.
*
* If nothing can be found, returns a 0.
*/
DLLEXPORT quint64 getTotalDiskB() const;
private:
static System* s_instance;

Loading…
Cancel
Save