2012-06-29 00:23:19 +08:00
|
|
|
#include "ProcReader.h"
|
|
|
|
#include "StringUtils.h"
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
map<string, string> GetCpuInfo()
|
|
|
|
{
|
|
|
|
map<string, string> result;
|
|
|
|
ifstream f;
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2012-06-29 00:23:19 +08:00
|
|
|
f.open("/proc/cpuinfo");
|
|
|
|
if (f.is_open())
|
|
|
|
{
|
2012-10-24 16:47:43 +08:00
|
|
|
while (!f.eof())
|
2012-10-17 07:18:30 +08:00
|
|
|
{
|
2012-10-24 16:47:43 +08:00
|
|
|
string tmp;
|
|
|
|
string key;
|
|
|
|
string value;
|
|
|
|
getline(f, tmp);
|
|
|
|
if (ParseString(tmp, key, value))
|
|
|
|
{
|
|
|
|
result[key] = value;
|
|
|
|
}
|
2012-10-17 07:18:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-29 00:23:19 +08:00
|
|
|
f.close();
|
2012-10-17 07:18:30 +08:00
|
|
|
|
2012-06-29 00:23:19 +08:00
|
|
|
return result;
|
|
|
|
}
|