Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WriteFileNative()

static unsafe int System.ConsolePal.WindowsConsoleStream.WriteFileNative ( IntPtr hFile,
ReadOnlySpan< byte > bytes,
bool useFileAPIs )
inlinestaticprivate

Definition at line 106 of file ConsolePal.cs.

107 {
108 if (bytes.IsEmpty)
109 {
110 return 0;
111 }
112 bool flag;
113 fixed (byte* ptr = bytes)
114 {
115 flag = ((!useFileAPIs) ? global::Interop.Kernel32.WriteConsole(hFile, ptr, bytes.Length / 2, out var _, IntPtr.Zero) : (global::Interop.Kernel32.WriteFile(hFile, ptr, bytes.Length, out var _, IntPtr.Zero) != 0));
116 }
117 if (flag)
118 {
119 return 0;
120 }
121 int lastPInvokeError = Marshal.GetLastPInvokeError();
122 if (lastPInvokeError == 232 || lastPInvokeError == 109)
123 {
124 return 0;
125 }
126 return lastPInvokeError;
127 }

References System.bytes, System.Runtime.InteropServices.Marshal.GetLastPInvokeError(), and System.IntPtr.Zero.

Referenced by System.ConsolePal.WindowsConsoleStream.Write().