[libcalamares] Some extra system-information functions
This commit is contained in:
parent
e83b4d33f8
commit
7a7e2b16cb
@ -232,7 +232,7 @@ System::targetEnvOutput( const QString& command,
|
|||||||
|
|
||||||
|
|
||||||
QPair<quint64, float>
|
QPair<quint64, float>
|
||||||
System::getTotalMemoryB()
|
System::getTotalMemoryB() const
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
struct sysinfo i;
|
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
|
* @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:
|
private:
|
||||||
static System* s_instance;
|
static System* s_instance;
|
||||||
|
Loading…
Reference in New Issue
Block a user