getpwnam function

Passwd getpwnam(
  1. String username
)

Retrieve the user database entry for the given username.

Throws a PosixException if username is is not a known user.

This function is a possible cancellation point and therefore not marked with __THROW.

Implementation

Passwd getpwnam(String username) {
  clearErrno();
  final cName = username.toNativeUtf8();

  _getpwnam ??= Libc().dylib.lookupFunction<
      ffi.Pointer<_passwd> Function(ffi.Pointer<Utf8>),
      _dart_getpwnam>('getpwnam');
  final passwd = _buildPasswd(
      _getpwnam!(
        cName,
      ),
      'Error occured attempting to retrieve Passwd for username: $username');

  malloc.free(cName);

  return passwd;
}