5 instantiations of SafeFileHandle
System.Console (1)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.FileDescriptors.cs (1)
19return new SafeFileHandle((IntPtr)fileNumber, ownsHandle: false);
System.IO.IsolatedStorage (1)
System\IO\IsolatedStorage\IsolatedStorageFileStream.cs (1)
68: base(new SafeFileHandle(initializationData.NestedStream.SafeFileHandle.DangerousGetHandle(), ownsHandle: false), access, bufferSize)
System.IO.MemoryMappedFiles (2)
System\IO\MemoryMappedFiles\MemoryMappedView.Unix.cs (2)
61fd = new SafeFileHandle(new IntPtr(-1), false); 103new SafeFileHandle(new IntPtr(-1), false), // ignore the actual fd even if there was one
System.Private.CoreLib (1)
src\libraries\System.Private.CoreLib\src\System\IO\FileStream.cs (1)
46SafeFileHandle safeHandle = new SafeFileHandle(handle, ownsHandle: ownsHandle);
272 references to SafeFileHandle
Microsoft.AspNetCore.InternalTesting (1)
DumpCollector\DumpCollector.Windows.cs (1)
35public static extern bool MiniDumpWriteDump(IntPtr hProcess, uint ProcessId, SafeFileHandle hFile, MINIDUMP_TYPE DumpType, ref MINIDUMP_EXCEPTION_INFORMATION ExceptionParam, IntPtr UserStreamParam, IntPtr CallbackParam);
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (2)
Listener\ServerOnExistingQueueTests.cs (1)
248out var requestQueueHandle);
ServerTests.cs (1)
52out var requestQueueHandle);
Microsoft.Build.Engine.UnitTests (2)
BackEnd\TargetUpToDateChecker_Tests.cs (2)
1012private static extern bool SetFileTime(SafeFileHandle hFile, ref long creationTime, 1041using (SafeFileHandle handle =
Microsoft.Build.Framework (7)
NativeMethods.cs (7)
1225private static SafeFileHandle OpenFileThroughSymlinks(string fullPath) 1250using (SafeFileHandle handle = OpenFileThroughSymlinks(fullPath)) 1773internal static extern bool CreatePipe(out SafeFileHandle hReadPipe, out SafeFileHandle hWritePipe, SecurityAttributes lpPipeAttributes, int nSize); 1777internal static extern bool ReadFile(SafeFileHandle hFile, byte[] lpBuffer, uint nNumberOfBytesToRead, out uint lpNumberOfBytesRead, IntPtr lpOverlapped); 1797internal static extern SafeFileHandle CreateFile( 1809SafeFileHandle hFile,
Microsoft.CodeAnalysis.Test.Utilities (1)
TempFiles\DisposableFile.cs (1)
62private static extern void SetFileInformationByHandle(SafeFileHandle handle, int fileInformationClass, ref uint fileDispositionInfoDeleteFile, int bufferSize);
MSBuildTaskHost (7)
NativeMethods.cs (7)
1225private static SafeFileHandle OpenFileThroughSymlinks(string fullPath) 1250using (SafeFileHandle handle = OpenFileThroughSymlinks(fullPath)) 1773internal static extern bool CreatePipe(out SafeFileHandle hReadPipe, out SafeFileHandle hWritePipe, SecurityAttributes lpPipeAttributes, int nSize); 1777internal static extern bool ReadFile(SafeFileHandle hFile, byte[] lpBuffer, uint nNumberOfBytesToRead, out uint lpNumberOfBytesRead, IntPtr lpOverlapped); 1797internal static extern SafeFileHandle CreateFile( 1809SafeFileHandle hFile,
mscorlib (1)
src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
23[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(Microsoft.Win32.SafeHandles.SafeFileHandle))]
netstandard (1)
netstandard.cs (1)
7[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(Microsoft.Win32.SafeHandles.SafeFileHandle))]
PresentationCore (15)
MS\Internal\FontCache\FontCacheUtil.cs (1)
816using (SafeFileHandle fileHandle = UnsafeNativeMethods.CreateFile(
System\Windows\Media\Imaging\BitmapDecoder.cs (4)
163SafeFileHandle safeFilehandle 235SafeFileHandle safeFilehandle = null; 995out SafeFileHandle safeFilehandle 1663private SafeFileHandle _safeFilehandle;
System\Windows\Media\Imaging\BitmapDownload.cs (1)
124SafeFileHandle fileHandle = MS.Win32.UnsafeNativeMethods.CreateFile(
System\Windows\Media\Imaging\BmpBitmapDecoder.cs (1)
70SafeFileHandle safeFilehandle
System\Windows\Media\Imaging\GifBitmapDecoder.cs (1)
70SafeFileHandle safeFilehandle
System\Windows\Media\Imaging\IconBitmapDecoder.cs (1)
70SafeFileHandle safeFilehandle
System\Windows\Media\Imaging\JpegBitmapDecoder.cs (1)
70SafeFileHandle safeFilehandle
System\Windows\Media\Imaging\PngBitmapDecoder.cs (1)
70SafeFileHandle safeFilehandle
System\Windows\Media\Imaging\TiffBitmapDecoder.cs (1)
70SafeFileHandle safeFilehandle
System\Windows\Media\Imaging\UnknownBitmapDecoder.cs (1)
60SafeFileHandle safeFilehandle
System\Windows\Media\Imaging\WmpBitmapDecoder.cs (1)
70SafeFileHandle safeFilehandle
System\Windows\Media\UnsafeNativeMethodsMilCoreApi.cs (1)
695Microsoft.Win32.SafeHandles.SafeFileHandle /*ULONG_PTR*/ hFileHandle,
System.Console (22)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Dup.cs (2)
13internal static partial SafeFileHandle Dup(SafeFileHandle oldfd);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.FileDescriptors.cs (4)
13internal static readonly SafeFileHandle STDIN_FILENO = CreateFileHandle(0); 14internal static readonly SafeFileHandle STDOUT_FILENO = CreateFileHandle(1); 15internal static readonly SafeFileHandle STDERR_FILENO = CreateFileHandle(2); 17private static SafeFileHandle CreateFileHandle(int fileNumber)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.FLock.cs (1)
21internal static partial int FLock(SafeFileHandle fd, LockOperations operation);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.GetWindowWidth.cs (1)
22internal static partial int GetWindowSize(SafeFileHandle terminalHandle, out WinSize winSize);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.InitializeTerminalAndSignalHandling.cs (1)
16internal static partial void SetKeypadXmit(SafeFileHandle terminalHandle, string terminfoString);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.IsATty.cs (1)
14internal static partial bool IsATty(SafeFileHandle fd);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Open.cs (1)
12internal static partial SafeFileHandle Open(string filename, OpenFlags flags, int mode);
System\ConsolePal.Unix.ConsoleStream.cs (2)
16private readonly SafeFileHandle _handle; 24internal UnixConsoleStream(SafeFileHandle handle, FileAccess access, bool useReadLine = false)
System\ConsolePal.Unix.cs (7)
40private static SafeFileHandle? s_terminalHandle; // Tracks the handle used for writing to the terminal. 663private static bool IsHandleRedirected(SafeFileHandle fd) 938private static unsafe int Read(SafeFileHandle fd, Span<byte> buffer) 948internal static void WriteToTerminal(ReadOnlySpan<byte> buffer, SafeFileHandle? handle = null, bool mayChangeCursorPosition = true) 959internal static unsafe void WriteFromConsoleStream(SafeFileHandle fd, ReadOnlySpan<byte> buffer) 973private static unsafe void Write(SafeFileHandle fd, ReadOnlySpan<byte> buffer, bool mayChangeCursorPosition = true) 1117internal static void WriteTerminalAnsiString(string? value, SafeFileHandle? handle = null, bool mayChangeCursorPosition = true)
System\TermInfo.DatabaseFactory.cs (2)
85private static bool TryOpen(string filePath, [NotNullWhen(true)] out SafeFileHandle? fd) 111SafeFileHandle? fd;
System.Diagnostics.Process (3)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.InitializeTerminalAndSignalHandling.cs (1)
16internal static partial void SetKeypadXmit(SafeFileHandle terminalHandle, string terminfoString);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.UnixFileSystemTypes.cs (2)
154private static partial uint GetFileSystemType(SafeFileHandle fd); 156internal static bool TryGetFileSystemType(SafeFileHandle fd, out UnixFileSystemTypes fileSystemType)
System.IO.FileSystem (1)
System.IO.FileSystem.cs (1)
4[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(Microsoft.Win32.SafeHandles.SafeFileHandle))]
System.IO.FileSystem.DriveInfo (2)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.UnixFileSystemTypes.cs (2)
154private static partial uint GetFileSystemType(SafeFileHandle fd); 156internal static bool TryGetFileSystemType(SafeFileHandle fd, out UnixFileSystemTypes fileSystemType)
System.IO.FileSystem.Primitives (1)
System.IO.FileSystem.Primitives.cs (1)
4[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(Microsoft.Win32.SafeHandles.SafeFileHandle))]
System.IO.FileSystem.Watcher (7)
src\libraries\Common\src\Interop\Linux\System.Native\Interop.INotify.cs (4)
14internal static partial SafeFileHandle INotifyInit(); 17internal static partial int INotifyAddWatch(SafeFileHandle fd, string pathName, uint mask); 20private static partial int INotifyRemoveWatch_private(SafeFileHandle fd, int wd); 22internal static int INotifyRemoveWatch(SafeFileHandle fd, int wd)
System\IO\FileSystemWatcher.Linux.cs (3)
36SafeFileHandle handle = Interop.Sys.INotifyInit(); 247private readonly SafeFileHandle _inotifyHandle; 289FileSystemWatcher watcher, SafeFileHandle inotifyHandle, string directoryPath,
System.IO.IsolatedStorage (1)
System\IO\IsolatedStorage\IsolatedStorageFileStream.cs (1)
341public override SafeFileHandle SafeFileHandle
System.IO.MemoryMappedFiles (26)
Microsoft\Win32\SafeMemoryMappedFileHandle.Unix.cs (2)
14internal SafeFileHandle? _fileStreamHandle; 39SafeFileHandle? fileHandle, bool ownsFileHandle, HandleInheritability inheritability,
src\libraries\Common\src\Interop\Unix\System.Native\Interop.FTruncate.cs (1)
12internal static partial int FTruncate(SafeFileHandle fd, long length);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.MemfdCreate.cs (1)
13internal static partial SafeFileHandle MemfdCreate(string name, int isReadonly);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.MMap.cs (1)
35SafeFileHandle fd, long offset);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Open.cs (1)
12internal static partial SafeFileHandle Open(string filename, OpenFlags flags, int mode);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.ShmOpen.cs (1)
12internal static partial SafeFileHandle ShmOpen(string name, OpenFlags flags, int mode);
System\IO\MemoryMappedFiles\MemoryMappedFile.cs (8)
14private readonly SafeFileHandle? _fileHandle; 28private MemoryMappedFile(SafeMemoryMappedFileHandle handle, SafeFileHandle fileHandle, bool leaveOpen) 127SafeFileHandle fileHandle = File.OpenHandle(path, mode, GetFileAccess(access), FileShare.Read, FileOptions.None); 171/// Creates a memory-mapped file from an existing file using a <see cref="SafeFileHandle"/>, 174/// <param name="fileHandle">The <see cref="SafeFileHandle"/> to the existing file. Caller is 208public static MemoryMappedFile CreateFromFile(SafeFileHandle fileHandle, string? mapName, long capacity, 263SafeFileHandle fileHandle = fileStream.SafeFileHandle; // access the property only once (it might perform a sys-call) 506private static void CleanupFile(SafeFileHandle fileHandle, bool existed, string path)
System\IO\MemoryMappedFiles\MemoryMappedFile.Unix.cs (10)
13private static void VerifyMemoryMappedFileAccess(MemoryMappedFileAccess access, long capacity, SafeFileHandle? fileHandle, long fileSize, out bool isRegularFile) 37static bool IsRegularFile(SafeFileHandle fileHandle) 50SafeFileHandle? fileHandle, string? mapName, 163private static SafeFileHandle CreateSharedBackingObject(Interop.Sys.MemoryMappedProtections protections, long capacity, HandleInheritability inheritability) 171private static SafeFileHandle? CreateSharedBackingObjectUsingMemoryShmOpen( 190SafeFileHandle fd; 273private static SafeFileHandle CreateSharedBackingObjectUsingMemoryMemfdCreate( 279SafeFileHandle fd = Interop.Sys.MemfdCreate(GenerateMapName(), isReadonly); 312private static SafeFileHandle CreateSharedBackingObjectUsingFile(Interop.Sys.MemoryMappedProtections protections, long capacity, HandleInheritability inheritability) 324SafeFileHandle fileHandle = File.OpenHandle(path, FileMode.CreateNew, TranslateProtectionsToFileAccess(protections), share);
System\IO\MemoryMappedFiles\MemoryMappedView.Unix.cs (1)
52SafeFileHandle fd;
System.IO.Pipes (2)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.FLock.cs (1)
21internal static partial int FLock(SafeFileHandle fd, LockOperations operation);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Open.cs (1)
12internal static partial SafeFileHandle Open(string filename, OpenFlags flags, int mode);
System.Net.Sockets (15)
System\Net\Sockets\Socket.cs (1)
3986private static SafeFileHandle? OpenFileHandle(string? name) => string.IsNullOrEmpty(name) ? null : File.OpenHandle(name, FileMode.Open, FileAccess.Read);
System\Net\Sockets\Socket.Unix.cs (1)
209using (SafeFileHandle? fileHandle = OpenFileHandle(fileName))
System\Net\Sockets\SocketAsyncContext.Unix.cs (3)
691public SafeFileHandle FileHandle = null!; // always set when constructed 2128public SocketError SendFile(SafeFileHandle fileHandle, long offset, long count, int timeout, out long bytesSent) 2158public SocketError SendFileAsync(SafeFileHandle fileHandle, long offset, long count, out long bytesSent, Action<long, SocketError> callback, CancellationToken cancellationToken = default)
System\Net\Sockets\SocketAsyncEventArgs.Unix.cs (3)
248SafeFileHandle[] fileHandles = new SafeFileHandle[elements.Length]; 266foreach (SafeFileHandle s in fileHandles)
System\Net\Sockets\SocketPal.Unix.cs (7)
371private static long SendFile(SafeSocketHandle socket, SafeFileHandle fileHandle, ref long offset, ref long count, out Interop.Error errno) 1036public static bool TryCompleteSendFile(SafeSocketHandle socket, SafeFileHandle handle, ref long offset, ref long count, ref long bytesSent, out SocketError errorCode) 1220public static SocketError SendFile(SafeSocketHandle handle, SafeFileHandle fileHandle) 2070private static SocketError SendFileAsync(SafeSocketHandle handle, SafeFileHandle fileHandle, long offset, long count, CancellationToken cancellationToken, Action<long, SocketError> callback) 2082Socket socket, TransmitFileOptions options, SendPacketsElement[] elements, SafeFileHandle[] fileHandles, CancellationToken cancellationToken, Action<long, SocketError> callback) 2100SafeFileHandle fileHandle = fileHandles[i] ?? e.FileStream!.SafeFileHandle; 2140foreach (SafeFileHandle fs in fileHandles)
System.Private.CoreLib (154)
src\libraries\Common\src\Interop\Unix\System.Native\Interop.CopyFile.cs (2)
13internal static partial int CopyFile(SafeFileHandle source, SafeFileHandle destination, long sourceLength);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.FAllocate.cs (1)
15internal static partial int FAllocate(SafeFileHandle fd, long offset, long length);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.FChMod.cs (1)
13internal static partial int FChMod(SafeFileHandle fd, int mode);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.FLock.cs (1)
21internal static partial int FLock(SafeFileHandle fd, LockOperations operation);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.FSync.cs (1)
12internal static partial int FSync(SafeFileHandle fd);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.FTruncate.cs (1)
12internal static partial int FTruncate(SafeFileHandle fd, long length);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.InitializeTerminalAndSignalHandling.cs (1)
16internal static partial void SetKeypadXmit(SafeFileHandle terminalHandle, string terminfoString);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.LSeek.cs (1)
19internal static partial long LSeek(SafeFileHandle fd, long offset, SeekWhence whence);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.Open.cs (1)
12internal static partial SafeFileHandle Open(string filename, OpenFlags flags, int mode);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.PosixFAdvise.cs (1)
33internal static partial int PosixFAdvise(SafeFileHandle fd, long offset, long length, FileAdvice advice);
src\libraries\Common\src\Interop\Unix\System.Native\Interop.UnixFileSystemTypes.cs (2)
154private static partial uint GetFileSystemType(SafeFileHandle fd); 156internal static bool TryGetFileSystemType(SafeFileHandle fd, out UnixFileSystemTypes fileSystemType)
src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeFileHandle.ThreadPoolValueTaskSource.cs (2)
32private readonly SafeFileHandle _fileHandle; 47internal ThreadPoolValueTaskSource(SafeFileHandle fileHandle)
src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs (8)
91private static SafeFileHandle Open(string path, Interop.Sys.OpenFlags flags, int mode, bool failForSymlink, out bool wasSymlink, 96SafeFileHandle handle = Interop.Sys.Open(path, flags, mode); 177internal static SafeFileHandle OpenReadOnly(string fullPath, FileOptions options, out long fileLength, out UnixFileMode filePermissions) 179SafeFileHandle handle = Open(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read, options, preallocationSize: 0, DefaultCreateMode, out fileLength, out filePermissions, false, out _, null); 184internal static SafeFileHandle Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, UnixFileMode? unixCreateMode = null, 190internal static SafeFileHandle? OpenNoFollowSymlink(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, out bool wasSymlink, UnixFileMode? unixCreateMode = null, 196private static SafeFileHandle Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, UnixFileMode openPermissions, 203SafeFileHandle? safeFileHandle = null;
src\libraries\System.Private.CoreLib\src\System\IO\File.cs (47)
137/// Initializes a new instance of the <see cref="SafeFileHandle" /> class with the specified path, creation mode, read/write and sharing permission, the access other SafeFileHandles can have to the same file, additional file options and the allocation size. 139/// <param name="path">A relative or absolute path for the file that the current <see cref="SafeFileHandle" /> instance will encapsulate.</param> 145/// <param name="options">An object that describes optional <see cref="SafeFileHandle" /> parameters to use.</param> 166public static SafeFileHandle OpenHandle(string path, FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read, 171return SafeFileHandle.Open(Path.GetFullPath(path), mode, access, share, options, preallocationSize); 191/// A <see cref="SafeFileHandle" /> to the file or directory for which to set the creation date and time information. 209public static void SetCreationTime(SafeFileHandle fileHandle, DateTime creationTime) 223/// A <see cref="SafeFileHandle" /> to the file or directory for which to set the creation date and time information. 241public static void SetCreationTimeUtc(SafeFileHandle fileHandle, DateTime creationTimeUtc) 254/// A <see cref="SafeFileHandle" /> to the file or directory for which to obtain creation date and time information. 266public static DateTime GetCreationTime(SafeFileHandle fileHandle) 279/// A <see cref="SafeFileHandle" /> to the file or directory for which to obtain creation date and time information. 291public static DateTime GetCreationTimeUtc(SafeFileHandle fileHandle) 304/// A <see cref="SafeFileHandle" /> to the file or directory for which to set the last access date and time information. 322public static void SetLastAccessTime(SafeFileHandle fileHandle, DateTime lastAccessTime) 335/// A <see cref="SafeFileHandle" /> to the file or directory for which to set the last access date and time information. 353public static void SetLastAccessTimeUtc(SafeFileHandle fileHandle, DateTime lastAccessTimeUtc) 366/// A <see cref="SafeFileHandle" /> to the file or directory for which to obtain last access date and time information. 378public static DateTime GetLastAccessTime(SafeFileHandle fileHandle) 391/// A <see cref="SafeFileHandle" /> to the file or directory for which to obtain last access date and time information. 403public static DateTime GetLastAccessTimeUtc(SafeFileHandle fileHandle) 416/// A <see cref="SafeFileHandle" /> to the file or directory for which to set the last write date and time information. 434public static void SetLastWriteTime(SafeFileHandle fileHandle, DateTime lastWriteTime) 447/// A <see cref="SafeFileHandle" /> to the file or directory for which to set the last write date and time information. 465public static void SetLastWriteTimeUtc(SafeFileHandle fileHandle, DateTime lastWriteTimeUtc) 478/// A <see cref="SafeFileHandle" /> to the file or directory for which to obtain last write date and time information. 490public static DateTime GetLastWriteTime(SafeFileHandle fileHandle) 503/// A <see cref="SafeFileHandle" /> to the file or directory for which to obtain last write date and time information. 515public static DateTime GetLastWriteTimeUtc(SafeFileHandle fileHandle) 528/// A <see cref="SafeFileHandle" /> to the file or directory for which the attributes are to be retrieved. 539public static FileAttributes GetAttributes(SafeFileHandle fileHandle) 552/// A <see cref="SafeFileHandle" /> to the file or directory for which <paramref name="fileAttributes"/> should be set. 565/// using the <see cref="SetAttributes(SafeFileHandle, FileAttributes)"/> method. 567public static void SetAttributes(SafeFileHandle fileHandle, FileAttributes fileAttributes) 591public static UnixFileMode GetUnixFileMode(SafeFileHandle fileHandle) 615public static void SetUnixFileMode(SafeFileHandle fileHandle, UnixFileMode mode) 699using (SafeFileHandle sfh = OpenHandle(path, FileMode.Open, FileAccess.Read, FileShare.Read, options)) 763using SafeFileHandle sfh = OpenHandle(path, FileMode.Create, FileAccess.Write, FileShare.Read); 813using SafeFileHandle fileHandle = OpenHandle(path, FileMode.Append, FileAccess.Write, FileShare.Read); 858using SafeFileHandle fileHandle = OpenHandle(path, FileMode.Append, FileAccess.Write, FileShare.Read, FileOptions.Asynchronous); 1178SafeFileHandle sfh = OpenHandle(path, FileMode.Open, FileAccess.Read, FileShare.Read, options); 1198private static async Task<byte[]> InternalReadAllBytesAsync(SafeFileHandle sfh, int count, CancellationToken cancellationToken) 1219private static async Task<byte[]> InternalReadAllBytesUnknownLengthAsync(SafeFileHandle sfh, CancellationToken cancellationToken) 1287using SafeFileHandle sfh = OpenHandle(path, FileMode.Create, FileAccess.Write, FileShare.Read, FileOptions.Asynchronous); 1460private static byte[] ReadAllBytesUnknownLength(SafeFileHandle sfh) 1510using SafeFileHandle fileHandle = OpenHandle(path, mode, FileAccess.Write, FileShare.Read, FileOptions.None, GetPreallocationSize(mode, contents, encoding, preambleSize)); 1566using SafeFileHandle fileHandle = OpenHandle(path, mode, FileAccess.Write, FileShare.Read, FileOptions.Asynchronous, GetPreallocationSize(mode, contents.Span, encoding, preambleSize));
src\libraries\System.Private.CoreLib\src\System\IO\File.Unix.cs (2)
13private static UnixFileMode GetUnixFileModeCore(SafeFileHandle fileHandle) 19private static void SetUnixFileModeCore(SafeFileHandle fileHandle, UnixFileMode mode)
src\libraries\System.Private.CoreLib\src\System\IO\FileStatus.SetTimes.OtherUnix.cs (3)
14internal void SetCreationTime(SafeFileHandle handle, DateTimeOffset time, bool asDirectory) => 17private void SetAccessOrWriteTime(SafeFileHandle? handle, string? path, DateTimeOffset time, bool isAccessTime, bool asDirectory) => 22private static Interop.Error SetCreationTimeCore(SafeFileHandle? handle, string? path, long seconds, long nanoseconds) =>
src\libraries\System.Private.CoreLib\src\System\IO\FileStatus.Unix.cs (21)
190internal FileAttributes GetAttributes(SafeFileHandle handle, bool continueOnError = false) 193private FileAttributes GetAttributes(SafeFileHandle? handle, ReadOnlySpan<char> path, ReadOnlySpan<char> fileName, bool continueOnError = false) 221internal void SetAttributes(SafeFileHandle handle, FileAttributes attributes, bool asDirectory) 224private void SetAttributes(SafeFileHandle? handle, string? path, FileAttributes attributes, bool asDirectory) 294internal DateTimeOffset GetCreationTime(SafeFileHandle handle, bool continueOnError = false) 297private DateTimeOffset GetCreationTime(SafeFileHandle? handle, ReadOnlySpan<char> path, bool continueOnError = false) 318internal DateTimeOffset GetLastAccessTime(SafeFileHandle handle, bool continueOnError = false) 321private DateTimeOffset GetLastAccessTime(SafeFileHandle? handle, ReadOnlySpan<char> path, bool continueOnError = false) 334internal void SetLastAccessTime(SafeFileHandle handle, DateTimeOffset time, bool asDirectory) 337private void SetLastAccessTime(SafeFileHandle? handle, string? path, DateTimeOffset time, bool asDirectory) 343internal DateTimeOffset GetLastWriteTime(SafeFileHandle handle, bool continueOnError = false) 346private DateTimeOffset GetLastWriteTime(SafeFileHandle? handle, ReadOnlySpan<char> path, bool continueOnError = false) 359internal void SetLastWriteTime(SafeFileHandle handle, DateTimeOffset time, bool asDirectory) 362internal void SetLastWriteTime(SafeFileHandle? handle, string? path, DateTimeOffset time, bool asDirectory) 370private unsafe void SetAccessOrWriteTimeCore(SafeFileHandle? handle, string? path, DateTimeOffset time, bool isAccessTime, bool checkCreationTime, bool asDirectory) 458internal UnixFileMode GetUnixFileMode(SafeFileHandle handle, bool continueOnError = false) 461private UnixFileMode GetUnixFileMode(SafeFileHandle? handle, ReadOnlySpan<char> path, bool continueOnError = false) 474internal void SetUnixFileMode(SafeFileHandle handle, UnixFileMode mode) 477private void SetUnixFileMode(SafeFileHandle? handle, string? path, UnixFileMode mode) 498internal void RefreshCaches(SafeFileHandle? handle, ReadOnlySpan<char> path) 558internal void EnsureCachesInitialized(SafeFileHandle? handle, ReadOnlySpan<char> path, bool continueOnError = false)
src\libraries\System.Private.CoreLib\src\System\IO\FileStream.cs (7)
46SafeFileHandle safeHandle = new SafeFileHandle(handle, ownsHandle: ownsHandle); 67private static void ValidateHandle(SafeFileHandle handle, FileAccess access, int bufferSize) 87private static void ValidateHandle(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync) 101public FileStream(SafeFileHandle handle, FileAccess access) 106public FileStream(SafeFileHandle handle, FileAccess access, int bufferSize) 113public FileStream(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync) 442public virtual SafeFileHandle SafeFileHandle => _strategy.SafeFileHandle;
src\libraries\System.Private.CoreLib\src\System\IO\FileSystem.Unix.cs (14)
37using SafeFileHandle src = SafeFileHandle.OpenReadOnly(sourceFullPath, FileOptions.None, out fileLength, out filePermissions); 47using SafeFileHandle dst = SafeFileHandle.Open(destFullPath, overwrite ? FileMode.Create : FileMode.CreateNew, 592public static FileAttributes GetAttributes(SafeFileHandle fileHandle) 598public static void SetAttributes(SafeFileHandle fileHandle, FileAttributes attributes) 611public static UnixFileMode GetUnixFileMode(SafeFileHandle fileHandle) 617public static void SetUnixFileMode(SafeFileHandle fileHandle, UnixFileMode mode) 623public static DateTimeOffset GetCreationTime(SafeFileHandle fileHandle) 629public static void SetCreationTime(SafeFileHandle fileHandle, DateTimeOffset time) 635public static DateTimeOffset GetLastAccessTime(SafeFileHandle fileHandle) 641public static unsafe void SetLastAccessTime(SafeFileHandle fileHandle, DateTimeOffset time) 647public static DateTimeOffset GetLastWriteTime(SafeFileHandle fileHandle) 653public static unsafe void SetLastWriteTime(SafeFileHandle fileHandle, DateTimeOffset time)
src\libraries\System.Private.CoreLib\src\System\IO\RandomAccess.cs (12)
23public static long GetLength(SafeFileHandle handle) 40public static void SetLength(SafeFileHandle handle, long length) 67public static int Read(SafeFileHandle handle, Span<byte> buffer, long fileOffset) 89public static long Read(SafeFileHandle handle, IReadOnlyList<Memory<byte>> buffers, long fileOffset) 113public static ValueTask<int> ReadAsync(SafeFileHandle handle, Memory<byte> buffer, long fileOffset, CancellationToken cancellationToken = default) 141public static ValueTask<long> ReadAsync(SafeFileHandle handle, IReadOnlyList<Memory<byte>> buffers, long fileOffset, CancellationToken cancellationToken = default) 168public static void Write(SafeFileHandle handle, ReadOnlySpan<byte> buffer, long fileOffset) 189public static void Write(SafeFileHandle handle, IReadOnlyList<ReadOnlyMemory<byte>> buffers, long fileOffset) 213public static ValueTask WriteAsync(SafeFileHandle handle, ReadOnlyMemory<byte> buffer, long fileOffset, CancellationToken cancellationToken = default) 241public static ValueTask WriteAsync(SafeFileHandle handle, IReadOnlyList<ReadOnlyMemory<byte>> buffers, long fileOffset, CancellationToken cancellationToken = default) 272public static void FlushToDisk(SafeFileHandle handle) 284private static void ValidateInput(SafeFileHandle handle, long fileOffset, bool allowUnseekableHandles = false)
src\libraries\System.Private.CoreLib\src\System\IO\RandomAccess.Unix.cs (9)
22internal static unsafe void SetFileLength(SafeFileHandle handle, long length) => 25internal static unsafe int ReadAtOffset(SafeFileHandle handle, Span<byte> buffer, long fileOffset) 61internal static unsafe long ReadScatterAtOffset(SafeFileHandle handle, IReadOnlyList<Memory<byte>> buffers, long fileOffset) 94internal static ValueTask<int> ReadAtOffsetAsync(SafeFileHandle handle, Memory<byte> buffer, long fileOffset, CancellationToken cancellationToken, OSFileStreamStrategy? strategy = null) 97private static ValueTask<long> ReadScatterAtOffsetAsync(SafeFileHandle handle, IReadOnlyList<Memory<byte>> buffers, long fileOffset, CancellationToken cancellationToken) 100internal static unsafe void WriteAtOffset(SafeFileHandle handle, ReadOnlySpan<byte> buffer, long fileOffset) 161internal static unsafe void WriteGatherAtOffset(SafeFileHandle handle, IReadOnlyList<ReadOnlyMemory<byte>> buffers, long fileOffset) 243internal static ValueTask WriteAtOffsetAsync(SafeFileHandle handle, ReadOnlyMemory<byte> buffer, long fileOffset, CancellationToken cancellationToken, OSFileStreamStrategy? strategy = null) 246private static ValueTask WriteGatherAtOffsetAsync(SafeFileHandle handle, IReadOnlyList<ReadOnlyMemory<byte>> buffers, long fileOffset, CancellationToken cancellationToken)
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\BufferedFileStreamStrategy.cs (1)
78internal override SafeFileHandle SafeFileHandle
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\DerivedFileStreamStrategy.cs (1)
45internal override SafeFileHandle SafeFileHandle
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\FileStreamHelpers.cs (1)
19internal static FileStreamStrategy ChooseStrategy(FileStream fileStream, SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync)
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\FileStreamHelpers.Unix.cs (6)
12private static UnixFileStreamStrategy ChooseStrategyCore(SafeFileHandle handle, FileAccess access, bool isAsync) => 33internal static long Seek(SafeFileHandle handle, long offset, SeekOrigin origin) => 36internal static void ThrowInvalidArgument(SafeFileHandle handle) => 40internal static void FlushToDisk(SafeFileHandle handle) 59internal static void Lock(SafeFileHandle handle, bool canWrite, long position, long length) 69internal static void Unlock(SafeFileHandle handle, long position, long length)
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\FileStreamStrategy.cs (1)
16internal abstract SafeFileHandle SafeFileHandle { get; }
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\OSFileStreamStrategy.cs (4)
14protected readonly SafeFileHandle _fileHandle; // only ever null if ctor throws 20internal OSFileStreamStrategy(SafeFileHandle handle, FileAccess access) 46_fileHandle = SafeFileHandle.Open(fullPath, mode, access, share, options, preallocationSize, unixCreateMode); 96internal sealed override SafeFileHandle SafeFileHandle
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\UnixFileStreamStrategy.cs (1)
10internal UnixFileStreamStrategy(SafeFileHandle handle, FileAccess access) : base(handle, access)
src\libraries\System.Private.CoreLib\src\System\TimeZoneInfo.Unix.NonAndroid.cs (1)
268using (SafeFileHandle sfh = File.OpenHandle(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net10.0\System.Runtime.Forwards.cs (1)
5[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(Microsoft.Win32.SafeHandles.SafeFileHandle))]