getlogin function
Return the login name of the user.
If there is no login name then null is returned.
If an error occures a PosixException is thrown.
This method is not thread safe.
Implementation
String? getlogin() {
_getlogin ??= Libc()
.dylib
.lookupFunction<ffi.Pointer<Utf8> Function(), _dart_getlogin>('getlogin');
final cName = _getlogin!();
if (cName == ffi.nullptr) {
// may be there is no login name or possibly an error occured.
final error = errno();
if (error != 0) {
throw PosixException('Call to getlogin() failed', error,
posixError: _getLogin_error(error));
}
}
// c_name points to static memory so we don't need to free it.
final name = cName == ffi.nullptr ? null : cName.toDartString();
return name;
}