Google celebrates Hispanic Heritage Month. See how.

connect method

*[<Null safety>](https://dart.dev/null-safety)*
  • @override

int connect (dynamic flags, int mode, InterfaceRequest request, [dynamic parentFlags])

override

Connects to this instance of PseudoDir and serves fidl_fuchsia_io.Directory over fidl.

Implementation

@override
int connect(OpenFlags flags, int mode, fidl.InterfaceRequest<Node> request,
    [OpenFlags? parentFlags]) {
  if (_isClosed) {
    sendErrorEvent(flags, ZX.ERR_NOT_SUPPORTED, request);
    return ZX.ERR_NOT_SUPPORTED;
  }
  // There should be no modeType* flags set, except for, possibly,
  // modeTypeDirectory when the target is a pseudo dir.
  if ((mode & ~modeProtectionMask) & ~modeTypeDirectory != 0) {
    sendErrorEvent(flags, ZX.ERR_INVALID_ARGS, request);
    return ZX.ERR_INVALID_ARGS;
  }

  var connectFlags = filterForNodeReference(flags);

  parentFlags ??= Flags.fsRightsDefault();
  // Grant POSIX clients additional rights.
  if (Flags.isPosixWritable(connectFlags)) {
    connectFlags |= parentFlags & OpenFlags.rightWritable;
  }
  if (Flags.isPosixExecutable(connectFlags)) {
    connectFlags |= parentFlags & OpenFlags.rightExecutable;
  }
  // Clear any remaining POSIX right expansion flags.
  connectFlags &= ~(OpenFlags.posixWritable | OpenFlags.posixExecutable);

  final status = _validateFlags(connectFlags);
  if (status != ZX.OK) {
    sendErrorEvent(connectFlags, status, request);
    return status;
  }
  final connection = _DirConnection(
      mode, connectFlags, this, fidl.InterfaceRequest(request.passChannel()));
  _connections.add(connection);
  return ZX.OK;
}