mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Unbuffering stdout
This commit is contained in:
parent
bc5c425d1b
commit
4a819762e6
3 changed files with 17 additions and 6 deletions
|
@ -183,8 +183,9 @@ namespace bf
|
|||
|
||||
class Console
|
||||
{
|
||||
private:
|
||||
BFRT_EXPORT static void PutChars(char* ptr, int len);
|
||||
public:
|
||||
BFRT_EXPORT static void PutChar(char c);
|
||||
BFRT_EXPORT static void ReopenHandles();
|
||||
};
|
||||
|
||||
|
|
|
@ -292,9 +292,20 @@ static void NTAPI TlsFreeFunc(void* ptr)
|
|||
gBfRtCallbacks.Thread_Exiting();
|
||||
}
|
||||
|
||||
void bf::System::Console::PutChar(char c)
|
||||
void bf::System::Console::PutChars(char* ptr, int len)
|
||||
{
|
||||
putchar(c);
|
||||
#ifdef BF_PLATFORM_WINDOWS
|
||||
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
if (handle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD numBytesWritten = 0;
|
||||
::WriteFile(handle, ptr, (DWORD)len, &numBytesWritten, NULL);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
putchar(ptr[i]);
|
||||
}
|
||||
|
||||
void bf::System::Console::ReopenHandles()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue