src/linux_parser.cpp
// TODO: Read and return the user associated with a process
// REMOVE: [[maybe_unused]] once you define the function
Read and return the user associated with a process
REMOVE: [[maybe_unused]] once you define the function
Read and return the user associated with a process REMOVE : [[ maybe_unused ]] once you define the function
string LinuxParser::User(int pid) 
{ 
  std::ifstream stream1(kPasswordPath);
  string buffer,line,X,U_name;
  string UID = Uid(pid);
  if(stream1.is_open())
  {
    while (std::getline(stream1, line))
    {
      std::replace(line.begin(), line.end(), ':',' ');
      std::istringstream linestream(line);
      while (linestream>>line>>X>>buffer)
      {
        if (buffer == UID){return U_name = line;}
      }
    }
  }
  return U_name; 
 }
string LinuxParser :: User ( int pid ) { std :: ifstream stream1 ( kPasswordPath ) ; string buffer , line , X , U_name ; string UID = Uid ( pid ) ; if ( stream1 . is_open ( ) ) { while ( std :: getline ( stream1 , line ) ) { std :: replace ( line . begin ( ) , line . end ( ) , ' ' , ' ' ) ; std :: istringstream linestream ( line ) ; while ( linestream >> line >> X >> buffer ) { if ( buffer == UID ) { return U_name = line ; } } } } return U_name ; }
TODO: Read and return the user associated with a process
REMOVE: [[maybe_unused]] once you define the function
TODO : Read and return the user associated with a process REMOVE : [[ maybe_unused ]] once you define the function
// buffer = "";