98 FileStreamStrategy strategy = (
UseNet5CompatStrategy ?
new Net5CompatFileStreamStrategy(
path, mode,
access,
share, (
bufferSize == 0) ? 1 :
bufferSize,
options, preallocationSize) :
EnableBufferingIfNeeded(
ChooseStrategyCore(
path, mode,
access,
share,
options, preallocationSize),
bufferSize));
139 if (
path.Length == 0)
169 else if (preallocationSize < 0)
181 if (preallocationSize > 0)
static unsafe int ReadFile(IntPtr handle, byte *bytes, int numBytesToRead, out int numBytesRead, IntPtr mustBeZero)
static unsafe bool CancelIoEx(SafeHandle handle, NativeOverlapped *lpOverlapped)
static bool UnlockFile(SafeFileHandle handle, int offsetLow, int offsetHigh, int countLow, int countHigh)
static bool SetFilePointerEx(SafeFileHandle hFile, long liDistanceToMove, out long lpNewFilePointer, uint dwMoveMethod)
static unsafe bool SetFileInformationByHandle(SafeFileHandle hFile, int FileInformationClass, void *lpFileInformation, uint dwBufferSize)
static bool LockFile(SafeFileHandle handle, int offsetLow, int offsetHigh, int countLow, int countHigh)
static bool FlushFileBuffers(SafeHandle hHandle)
static bool GetBooleanConfig(string configName, bool defaultValue)
static ArrayPool< T > Shared
void UnsafeOnCompleted(Action continuation)
AsyncCopyToAwaitable GetAwaiter()
readonly SafeFileHandle _fileHandle
void ResetForNextOperation()
static readonly Action s_sentinel
static unsafe readonly IOCompletionCallback s_callback
AsyncCopyToAwaitable(SafeFileHandle fileHandle)
static unsafe void IOCallback(uint errorCode, uint numBytes, NativeOverlapped *pOVERLAP)
unsafe NativeOverlapped * _nativeOverlapped
void OnCompleted(Action continuation)
static unsafe async Task AsyncModeCopyToAsync(SafeFileHandle handle, bool canSeek, long filePosition, Stream destination, int bufferSize, CancellationToken cancellationToken)
static unsafe bool TrySetFileLength(SafeFileHandle handle, long length, out int errorCode)
static void ValidateArguments(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, long preallocationSize)
static FileStreamStrategy ChooseStrategy(FileStream fileStream, SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync)
static FileStreamStrategy ChooseStrategyCore(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize)
static FileStreamStrategy WrapIfDerivedType(FileStream fileStream, FileStreamStrategy strategy)
static int GetLastWin32ErrorAndDisposeHandleIfInvalid(SafeFileHandle handle)
static unsafe int ReadFileNative(SafeFileHandle handle, Span< byte > bytes, NativeOverlapped *overlapped, out int errorCode)
static void SerializationGuard(FileAccess access)
static void SetFileLength(SafeFileHandle handle, long length)
static void Lock(SafeFileHandle handle, bool canWrite, long position, long length)
static int s_cachedSerializationSwitch
static void Unlock(SafeFileHandle handle, long position, long length)
static void FlushToDisk(SafeFileHandle handle)
static OSFileStreamStrategy ChooseStrategyCore(SafeFileHandle handle, FileAccess access, bool isAsync)
static long Seek(SafeFileHandle handle, long offset, SeekOrigin origin, bool closeInvalidHandle=false)
static void ThrowInvalidArgument(SafeFileHandle handle)
static FileStreamStrategy EnableBufferingIfNeeded(FileStreamStrategy strategy, int bufferSize)
static FileStreamStrategy ChooseStrategy(FileStream fileStream, string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, long preallocationSize)
static void ValidateArgumentsForPreallocation(FileMode mode, FileAccess access)
static bool UseNet5CompatStrategy
static bool IsIoRelatedException(Exception e)
static Exception GetExceptionForLastWin32Error(string path="")
static Exception GetExceptionForWin32Error(int errorCode, string path="")
static int GetLastPInvokeError()
static void ThrowIfDeserializationInProgress()
static string ArgumentOutOfRange_Enum
static string Format(string resourceFormat, object p1)
static string ArgumentNull_Path
static string Argument_InvalidFileModeAndAccessCombo
static string ArgumentOutOfRange_FileLengthTooBig
static string Argument_InvalidPreallocateAccess
static string Argument_EmptyPath
static string Argument_InvalidPreallocateMode
static string Argument_InvalidAppendMode
static int CompareExchange(ref int location1, int value, int comparand)
static Task Run(Action action)
static unsafe? object GetNativeOverlappedState(NativeOverlapped *overlapped)
static void ThrowArgumentOutOfRangeException_NeedNonNegNum(string paramName)
unsafe delegate void IOCompletionCallback(uint errorCode, uint numBytes, NativeOverlapped *pOVERLAP)
static readonly IntPtr Zero