Differences From Artifact [4abac542f9]:
- File src/OFStdIOStream_Win32Console.m — part of check-in [c1e949a8c6] at 2019-03-09 10:48:04 on branch trunk — Several minor fixes (user: js, size: 8698) [annotate] [blame] [check-ins using]
To Artifact [7e7d715431]:
- File
src/OFStdIOStream_Win32Console.m
— part of check-in
[0f8a72d43c]
at
2019-03-24 13:19:50
on branch trunk
— Derive of_std{in,out,err} from std{in,out,err}
Previously, this just assumed the existance of file descriptors 0, 1 and
2 - however, in GUI applications on Windows, these were missing when not
started from a console. (user: js, size: 8746) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #define OF_STDIO_STREAM_WIN32_CONSOLE_M #include "config.h" #include <assert.h> #include <errno.h> #import "OFStdIOStream_Win32Console.h" #import "OFStdIOStream+Private.h" #import "OFString.h" #import "OFData.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #include <windows.h> @implementation OFStdIOStream_Win32Console + (void)load { | > > > > > > > | | > | | > | | < < | < < < < < | < < < | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #define OF_STDIO_STREAM_WIN32_CONSOLE_M #include "config.h" #include <assert.h> #include <errno.h> #include <io.h> #import "OFStdIOStream_Win32Console.h" #import "OFStdIOStream+Private.h" #import "OFString.h" #import "OFData.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #include <windows.h> @implementation OFStdIOStream_Win32Console + (void)load { int fd; if (self != [OFStdIOStream_Win32Console class]) return; if ((fd = _fileno(stdin)) >= 0) of_stdin = [[OFStdIOStream_Win32Console alloc] of_initWithFileDescriptor: fd]; if ((fd = _fileno(stdout)) >= 0) of_stdout = [[OFStdIOStream_Win32Console alloc] of_initWithFileDescriptor: fd]; if ((fd = _fileno(stderr)) >= 0) of_stderr = [[OFStdIOStream_Win32Console alloc] of_initWithFileDescriptor: fd]; } - (instancetype)of_initWithFileDescriptor: (int)fd { self = [super of_initWithFileDescriptor: fd]; @try { DWORD mode; _handle = (HANDLE)_get_osfhandle(fd); if (_handle == INVALID_HANDLE_VALUE) @throw [OFInvalidArgumentException exception]; /* Not a console: Treat it as a regular OFStdIOStream */ if (!GetConsoleMode(_handle, &mode)) object_setClass(self, [OFStdIOStream class]); } @catch (id e) { [self release]; @throw e; |
︙ | ︙ |