Skip to content

Commit

Permalink
Revert "Use os-release instead of lsb-release for Linux OS Information (
Browse files Browse the repository at this point in the history
#41)"

This reverts commit f3b490f.
  • Loading branch information
lfreist committed Jun 22, 2023
1 parent 8c7ad6b commit 0825af4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/apple/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ int CPU::getRegularClockSpeed_kHz() {
return -1;
}

int CPU::getCacheSize_Bytes() { return -1; }
int CPU::getCacheSize_Bytes() {
return -1;
}

// =====================================================================================================================
// _____________________________________________________________________________________________________________________
Expand Down
20 changes: 8 additions & 12 deletions src/linux/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ namespace hwinfo {
// _____________________________________________________________________________________________________________________
std::string OS::getFullName() {
std::string line;
std::ifstream stream("/etc/os-release");
std::ifstream stream("/etc/lsb-release");
if (!stream) {
return "Linux <unknown version>";
}
while (getline(stream, line)) {
if (starts_with(line, "PRETTY_NAME")) {
if (starts_with(line, "DISTRIB_DESCRIPTION")) {
line = line.substr(line.find('=') + 1, line.length());
// remove \" at begin and end of the substring result
return {line.begin() + 1, line.end() - 1};
Expand All @@ -38,15 +38,13 @@ std::string OS::getFullName() {
// _____________________________________________________________________________________________________________________
std::string OS::getName() {
std::string line;
std::ifstream stream("/etc/os-release");
std::ifstream stream("/etc/lsb-release");
if (!stream) {
return "Linux";
}
while (getline(stream, line)) {
if (starts_with(line, "NAME")) {
line = line.substr(line.find('=') + 1, line.length());
// remove \" at begin and end of the substring result
return {line.begin() + 1, line.end() - 1};
if (starts_with(line, "DISTRIB_ID")) {
return line.substr(line.find('=') + 1, line.length());
}
}
stream.close();
Expand All @@ -56,15 +54,13 @@ std::string OS::getName() {
// _____________________________________________________________________________________________________________________
std::string OS::getVersion() {
std::string line;
std::ifstream stream("/etc/os-release");
std::ifstream stream("/etc/lsb-release");
if (!stream) {
return "<unknown version>";
}
while (getline(stream, line)) {
if (starts_with(line, "VERSION_ID")) {
line = line.substr(line.find('=') + 1, line.length());
// remove \" at begin and end of the substring result
return {line.begin() + 1, line.end() - 1};
if (starts_with(line, "DISTRIB_RELEASE")) {
return line.substr(line.find('=') + 1, line.length());
}
}
stream.close();
Expand Down

0 comments on commit 0825af4

Please sign in to comment.