Fix compilation of linux support in the reporter.

Originally committed to SVN as r5144.
This commit is contained in:
Amar Takhar 2011-01-08 15:38:30 +00:00
parent 55803684c3
commit 69af40edc6
2 changed files with 17 additions and 17 deletions

View file

@ -42,22 +42,22 @@ std::string PlatformUnixLinux::CPUSpeed() {
// due to SMT/HyperThreading. // due to SMT/HyperThreading.
// For now report the logical CPU count and no number of cores; this seems // For now report the logical CPU count and no number of cores; this seems
// to make the most sense. // to make the most sense.
std::string PlatformUnixLinux::CPUCores() { int PlatformUnixLinux::CPUCores() {
return ""; return -1;
}; };
std::string PlatformUnixLinux::CPUCount() { int PlatformUnixLinux::CPUCount() {
// This returns the index of the last processor. // This returns the index of the last processor.
// Increment and return as string. // Increment and return as string.
std::string procIndex = getProcValue("/proc/cpuinfo", "processor\t"); wxString procIndex = getProcValue("/proc/cpuinfo", "processor\t");
if (procIndex.IsNumber()) { if (procIndex.IsNumber()) {
long val = 0; long val = 0;
procIndex.ToLong(&val); procIndex.ToLong(&val);
return wxString::Format("%ld", val + 1); return val + 1;
} }
// Fallback // Fallback
return "1"; return 1;
}; };
std::string PlatformUnixLinux::CPUFeatures() { std::string PlatformUnixLinux::CPUFeatures() {
@ -68,16 +68,16 @@ std::string PlatformUnixLinux::CPUFeatures2() {
return ""; return "";
}; };
std::string PlatformUnixLinux::Memory() { uint64_t PlatformUnixLinux::Memory() {
std::string memKb = getProcValue("/proc/meminfo", "MemTotal"); wxString memKb = getProcValue("/proc/meminfo", "MemTotal");
memKb = memKb.BeforeFirst(' '); memKb = memKb.BeforeFirst(' ');
if (memKb.IsNumber()) { if (memKb.IsNumber()) {
long val = 0; long val = 0;
memKb.ToLong(&val); memKb.ToLong(&val);
return wxString::Format("%ld", val * 1024); return val * 1024;
} }
return ""; return -1;
}; };
std::string PlatformUnixLinux::UnixLibraries() { std::string PlatformUnixLinux::UnixLibraries() {
@ -88,22 +88,22 @@ std::string PlatformUnixLinux::UnixLibraries() {
* @brief Parse a /proc "key: value" style text file and extract a value. * @brief Parse a /proc "key: value" style text file and extract a value.
* @return The last valid value * @return The last valid value
*/ */
std::string PlatformUnixLinux::getProcValue(const std::string path, const std::string key) { std::string PlatformUnixLinux::getProcValue(const wxString path, const wxString key) {
const std::string prefix = std::string(key) + ":"; const wxString prefix = wxString(key) + ":";
wxTextFile *file = new wxTextFile(path); wxTextFile *file = new wxTextFile(path);
std::string val = std::string(); wxString val = std::string();
file->Open(); file->Open();
for (std::string str = file->GetFirstLine(); !file->Eof(); str = file->GetNextLine()) { for (wxString str = file->GetFirstLine(); !file->Eof(); str = file->GetNextLine()) {
str.Trim(false); str.Trim(false);
if (str.StartsWith(prefix)) { if (str.StartsWith(prefix)) {
val = std::string(str.Mid(key.Len() + 1)); val = wxString(str.Mid(key.Len() + 1));
val.Trim(false); val.Trim(false);
} }
} }
file->Close(); file->Close();
delete file; delete file;
return val; return std::string(val);
}; };

View file

@ -38,5 +38,5 @@ public:
// Unix Specific // Unix Specific
virtual std::string UnixLibraries(); virtual std::string UnixLibraries();
private: private:
virtual std::string getProcValue(const std::string path, const std::string key); virtual std::string getProcValue(const wxString path, const wxString key);
}; };