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

◆ WriteSyncUsingAsyncHandle()

static unsafe void System.IO.RandomAccess.WriteSyncUsingAsyncHandle ( SafeFileHandle handle,
ReadOnlySpan< byte > buffer,
long fileOffset )
inlinestaticprivate

Definition at line 323 of file RandomAccess.cs.

324 {
325 if (buffer.IsEmpty)
326 {
327 return;
328 }
329 handle.EnsureThreadPoolBindingInitialized();
330 CallbackResetEvent callbackResetEvent = new CallbackResetEvent(handle.ThreadPoolBinding);
331 NativeOverlapped* ptr = null;
332 try
333 {
335 fixed (byte* bytes = &MemoryMarshal.GetReference(buffer))
336 {
339 if (num == 997)
340 {
341 callbackResetEvent.WaitOne();
342 num = 0;
343 }
344 if (num == 0)
345 {
348 {
349 return;
350 }
352 }
353 switch (num)
354 {
355 case 232:
356 break;
357 case 87:
358 throw new IOException(SR.IO_FileTooLong);
359 default:
360 throw Win32Marshal.GetExceptionForWin32Error(num, handle.Path);
361 }
362 }
363 }
364 finally
365 {
366 if (ptr != null)
367 {
368 callbackResetEvent.FreeNativeOverlapped(ptr);
369 }
370 callbackResetEvent.Dispose();
371 }
372 }
static unsafe int WriteFile(IntPtr handle, byte *bytes, int numBytesToWrite, out int numBytesWritten, IntPtr mustBeZero)
static unsafe bool GetOverlappedResult(SafeFileHandle hFile, NativeOverlapped *lpOverlapped, ref int lpNumberOfBytesTransferred, bool bWait)
static Memory< byte > buffer
static unsafe NativeOverlapped * GetNativeOverlappedForAsyncHandle(ThreadPoolBoundHandle threadPoolBinding, long fileOffset, CallbackResetEvent resetEvent)
static Memory< byte > long fileOffset
static int GetLastWin32ErrorAndDisposeHandleIfInvalid(SafeFileHandle handle)

References System.IO.RandomAccess.buffer, System.bytes, System.IO.RandomAccess.fileOffset, System.IO.Win32Marshal.GetExceptionForWin32Error(), System.IO.Strategies.FileStreamHelpers.GetLastWin32ErrorAndDisposeHandleIfInvalid(), System.IO.RandomAccess.GetNativeOverlappedForAsyncHandle(), Interop.Kernel32.GetOverlappedResult(), System.handle, System.SR.IO_FileTooLong, Interop.Kernel32.WriteFile(), and System.IntPtr.Zero.

Referenced by System.IO.RandomAccess.WriteAtOffset().