src/linux_parser.cpp
string LinuxParser::User(int pid) 
{ 
  string userID = Uid(pid);
  string line, userName, x, userIDstring,token;

  std::ifstream filestream(kPasswordPath);

  if(filestream.is_open())
  {
    while(std::getline(filestream, line))
    {
      
      std::replace(line.begin(), line.end(), ':', ' ');
      std::istringstream linestream(line);
      linestream >> userName >> x >> userIDstring;

      if(userIDstring == userID)
      {
        break;
      }
    }
  }
  else
  {
    return string();
  }
  
  return userName;
}
// Read and return the user associated with a process
Read and return the user associated with a process
Read and return the user associated with a process
string LinuxParser::User(int pid) 
{ 
  string userID = Uid(pid);
  string line, userName, x, userIDstring,token;
  std::ifstream filestream(kPasswordPath);
  if(filestream.is_open())
  {
    while(std::getline(filestream, line))
    {
      std::replace(line.begin(), line.end(), ':', ' ');
      std::istringstream linestream(line);
      linestream >> userName >> x >> userIDstring;
      if(userIDstring == userID)
      {
        break;
      }
    }
  }
  else
  {
    return string();
  }
  return userName;
}
string LinuxParser :: User ( int pid ) { string userID = Uid ( pid ) ; string line , userName , x , userIDstring , token ; std :: ifstream filestream ( kPasswordPath ) ; if ( filestream . is_open ( ) ) { while ( std :: getline ( filestream , line ) ) { std :: replace ( line . begin ( ) , line . end ( ) , ' ' , ' ' ) ; std :: istringstream linestream ( line ) ; linestream >> userName >> x >> userIDstring ; if ( userIDstring == userID ) { break ; } } } else { return string ( ) ; } return userName ; }
Read and return the user associated with a process
Read and return the user associated with a process