src/linux_parser.cpp
// Done: 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 uid = Uid(pid);
  string line, User, field_name, value;
  std::ifstream filestream(kPasswordPath);
  if (filestream.is_open()) {
    while (std::getline(filestream, line)) {
      if (line.find(uid) != string::npos) {
        User = line.substr(0, (line.find(':')));
      }
    }
  }
  return User;
}
string LinuxParser :: User ( int pid ) { string uid = Uid ( pid ) ; string line , User , field_name , value ; std :: ifstream filestream ( kPasswordPath ) ; if ( filestream . is_open ( ) ) { while ( std :: getline ( filestream , line ) ) { if ( line . find ( uid ) != string :: npos ) { User = line . substr ( 0 , ( line . find ( ' ' ) ) ) ; } } } return User ; }
Done: Read and return the user associated with a process
Done : Read and return the user associated with a process