public static bool IsAtty(RubyIO/*!*/ self) {
ConsoleStreamType? console = self.ConsoleStreamType;
if (console == null) {
return self.GetStream().BaseStream == Stream.Null;
}
int fd = GetStdHandleFd(console.Value);
switch (Environment.OSVersion.Platform) {
case PlatformID.Win32NT:
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.WinCE:
IntPtr handle = GetStdHandle(fd);
if (handle == IntPtr.Zero) {
throw new Win32Exception();
}
return GetFileType(handle) == FILE_TYPE_CHAR;
default:
return isatty(fd) == 1;
}
}