src/linux_parser.cpp
// DONE: An example of how to read data from the filesystem
An example of how to read data from the filesystem
An example of how to read data from the filesystem
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;
        }
      }
    }
  }
  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 ; } } } } return value ; }
DONE: An example of how to read data from the filesystem
DONE : An example of how to read data from the filesystem
// to perserve the entire string "Ubuntu 16.04.7 LTS" // operate on the string "Ubuntu 16.04.7 LTS"