src/linux_parser.cpp
// Read and return the operating system name
Read and return the operating system name
Read and return the operating system name
string LinuxParser::OperatingSystem() {
  string line;
  string key;
  string value;
  std::ifstream filestream(kOSPath);
  if (filestream.is_open()) {
    while (std::getline(filestream, line)) {
      std::replace(line.begin(), line.end(), ' ', '_');
      std::replace(line.begin(), line.end(), '=', ' ');
      std::replace(line.begin(), line.end(), '"', ' ');
      std::istringstream linestream(line);
      while (linestream >> key >> value) {
        if (key == "PRETTY_NAME") {
          std::replace(value.begin(), value.end(), '_', ' ');
          return value;
        }
      }
    }
  }
  filestream.close();
  return value;
}
string LinuxParser :: OperatingSystem ( ) { string line ; string key ; string value ; std :: ifstream filestream ( kOSPath ) ; if ( filestream . is_open ( ) ) { while ( std :: getline ( filestream , line ) ) { std :: replace ( line . begin ( ) , line . end ( ) , ' ' , ' ' ) ; std :: replace ( line . begin ( ) , line . end ( ) , ' ' , ' ' ) ; std :: replace ( line . begin ( ) , line . end ( ) , ' ' , ' ' ) ; std :: istringstream linestream ( line ) ; while ( linestream >> key >> value ) { if ( key == " " ) { std :: replace ( value . begin ( ) , value . end ( ) , ' ' , ' ' ) ; return value ; } } } } filestream . close ( ) ; return value ; }
Read and return the operating system name
Read and return the operating system name