StdHandleCalls typedef

StdHandleCalls = ({void Function(int handle) closeHandle, int Function(int fd) crtHandle, int Function(int fd) duplicate, int Function(int fd) getStdHandle, bool Function(int handle) isConsole, bool Function(int which, int handle) setStdHandle})

The Win32 and UCRT calls alignStdHandles makes, injectable for tests.

Implementation

typedef StdHandleCalls = ({
  /// `_get_osfhandle(fd)` of the shared UCRT; -1 when the fd is closed.
  int Function(int fd) crtHandle,
  int Function(int which) getStdHandle,

  /// `GetConsoleMode` succeeds: a console, not NUL or a COM port, which
  /// `GetFileType` reports as the same FILE_TYPE_CHAR.
  bool Function(int handle) isConsole,

  /// A process-local duplicate, 0 when DuplicateHandle fails.
  int Function(int handle) duplicate,
  bool Function(int which, int handle) setStdHandle,
  void Function(int handle) closeHandle,
});