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

◆ ReadSyncUsingAsyncHandle()

static unsafe int System.IO.RandomAccess.ReadSyncUsingAsyncHandle ( SafeFileHandle handle,
Span< byte > buffer,
long fileOffset )
inlinestaticprivate

Definition at line 254 of file RandomAccess.cs.

255 {
256 handle.EnsureThreadPoolBindingInitialized();
257 CallbackResetEvent callbackResetEvent = new CallbackResetEvent(handle.ThreadPoolBinding);
258 NativeOverlapped* ptr = null;
259 try
260 {
262 fixed (byte* bytes = &MemoryMarshal.GetReference(buffer))
263 {
266 if (num == 997)
267 {
268 callbackResetEvent.WaitOne();
269 num = 0;
270 }
271 if (num == 0)
272 {
275 {
277 }
279 }
280 if (num == 38 || num == 109)
281 {
282 ptr->InternalLow = IntPtr.Zero;
283 return 0;
284 }
285 throw Win32Marshal.GetExceptionForWin32Error(num, handle.Path);
286 }
287 }
288 finally
289 {
290 if (ptr != null)
291 {
292 callbackResetEvent.FreeNativeOverlapped(ptr);
293 }
294 callbackResetEvent.Dispose();
295 }
296 }
static unsafe int ReadFile(IntPtr handle, byte *bytes, int numBytesToRead, out int numBytesRead, 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, Interop.Kernel32.ReadFile(), and System.IntPtr.Zero.

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