11 instantiations of SafeFileHandle
Aspire.Hosting.Browsers (1)
Aspire.Hosting.Browsers.Tests (1)
NuGet.Packaging (1)
System.Console (1)
System.IO.IsolatedStorage (1)
System.IO.MemoryMappedFiles (2)
System.Private.CoreLib (4)
517 references to SafeFileHandle
aspire (19)
Aspire.Cli.Tests (2)
Aspire.Hosting.Browsers (1)
Aspire.Hosting.Browsers.Tests (1)
csc (3)
dotnet (3)
dotnet-dev-certs (5)
Microsoft.AspNetCore.DeveloperCertificates.XPlat (5)
Microsoft.AspNetCore.InternalTesting (1)
Microsoft.AspNetCore.Server.Kestrel.Core (5)
Microsoft.Build.Tasks.CodeAnalysis (3)
Microsoft.CodeAnalysis (3)
Microsoft.CodeAnalysis.Workspaces (3)
Microsoft.NET.Build.Containers (3)
Microsoft.TestPlatform.Extensions.BlameDataCollector (1)
mscorlib (1)
netstandard (1)
NuGet.Packaging (1)
PresentationCore (15)
RepoTasks (5)
System.Console (36)
System.Diagnostics.PerformanceCounter (3)
System.Diagnostics.Process (90)
Microsoft\Win32\SafeHandles\SafeProcessHandle.Unix.cs (21)
202private delegate SafeProcessHandle StartWithShellExecuteDelegate(ProcessStartInfo startInfo, SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle, SafeFileHandle? stderrHandle, out ProcessWaitState.Holder? waitStateHolder);
205private static SafeProcessHandle StartCore(ProcessStartInfo startInfo, SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle, SafeFileHandle? stderrHandle, SafeHandle[]? inheritedHandlesSnapshot = null)
208internal static SafeProcessHandle StartCore(ProcessStartInfo startInfo, SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle,
209SafeFileHandle? stderrHandle, SafeHandle[]? inheritedHandles, out ProcessWaitState.Holder? waitStateHolder)
246internal static unsafe SafeProcessHandle StartWithCallback(ProcessStartInfo startInfo, SafeFileHandle? stdinFd, SafeFileHandle? stdoutHandle, SafeFileHandle? stderrHandle,
356private static SafeProcessHandle StartWithShellExecute(ProcessStartInfo startInfo, SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle,
357SafeFileHandle? stderrHandle, out ProcessWaitState.Holder? waitStateHolder)
425private static bool UsesTerminal(SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle, SafeFileHandle? stderrHandle)
432SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle, SafeFileHandle? stderrHandle,
System\Diagnostics\Process.cs (28)
1285SafeFileHandle? parentInputPipeHandle = null;
1286SafeFileHandle? parentOutputPipeHandle = null;
1287SafeFileHandle? parentErrorPipeHandle = null;
1289SafeFileHandle? childInputHandle = null;
1290SafeFileHandle? childOutputHandle = null;
1291SafeFileHandle? childErrorHandle = null;
1331ref SafeFileHandle? parentInputPipeHandle,
1332ref SafeFileHandle? parentOutputPipeHandle,
1333ref SafeFileHandle? parentErrorPipeHandle,
1334ref SafeFileHandle? childInputHandle,
1335ref SafeFileHandle? childOutputHandle,
1336ref SafeFileHandle? childErrorHandle)
1358SafeFileHandle.CreateAnonymousPipe(out childInputHandle, out parentInputPipeHandle);
1367SafeFileHandle.CreateAnonymousPipe(out parentOutputPipeHandle, out childOutputHandle, asyncRead: OperatingSystem.IsWindows());
1376SafeFileHandle.CreateAnonymousPipe(out parentErrorPipeHandle, out childErrorHandle, asyncRead: OperatingSystem.IsWindows());
1393SafeFileHandle nullDeviceHandle = File.OpenNullHandle();
1407private static void CloseChildHandles(ProcessStartInfo startInfo, SafeFileHandle? childInputHandle, SafeFileHandle? childOutputHandle, SafeFileHandle? childErrorHandle)
1429private void CreateStandardStreams(ProcessStartInfo startInfo, SafeFileHandle? parentInputPipeHandle, SafeFileHandle? parentOutputPipeHandle, SafeFileHandle? parentErrorPipeHandle)
1467SafeFileHandle? parentInputPipeHandle = null;
1468SafeFileHandle? parentOutputPipeHandle = null;
1469SafeFileHandle? parentErrorPipeHandle = null;
1471SafeFileHandle? childInputHandle = null;
1472SafeFileHandle? childOutputHandle = null;
1473SafeFileHandle? childErrorHandle = null;
System\Diagnostics\Process.Unix.cs (7)
428private bool StartCore(ProcessStartInfo startInfo, SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle, SafeFileHandle? stderrHandle, SafeHandle[]? inheritedHandles)
434private bool StartCoreWithCallback(ProcessStartInfo startInfo, SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle, SafeFileHandle? stderrHandle, Func<UnixProcessStartArguments, int> callback)
479private static AnonymousPipeClientStream OpenStream(SafeFileHandle handle, FileAccess access)
System\Diagnostics\ProcessStartInfo.cs (18)
172/// Gets or sets a <see cref="SafeFileHandle"/> that will be used as the standard input of the child process.
180/// Use <see cref="SafeFileHandle.CreateAnonymousPipe"/> to create a pair of connected pipe handles,
194/// <value>A <see cref="SafeFileHandle"/> to use as the standard input handle of the child process, or <see langword="null"/> to use the default behavior.</value>
195public SafeFileHandle? StandardInputHandle { get; set; }
198/// Gets or sets a <see cref="SafeFileHandle"/> that will be used as the standard output of the child process.
206/// Use <see cref="SafeFileHandle.CreateAnonymousPipe"/> to create a pair of connected pipe handles,
220/// <value>A <see cref="SafeFileHandle"/> to use as the standard output handle of the child process, or <see langword="null"/> to use the default behavior.</value>
221public SafeFileHandle? StandardOutputHandle { get; set; }
224/// Gets or sets a <see cref="SafeFileHandle"/> that will be used as the standard error of the child process.
232/// Use <see cref="SafeFileHandle.CreateAnonymousPipe"/> to create a pair of connected pipe handles,
246/// <value>A <see cref="SafeFileHandle"/> to use as the standard error handle of the child process, or <see langword="null"/> to use the default behavior.</value>
247public SafeFileHandle? StandardErrorHandle { get; set; }
258/// Only <see cref="SafeFileHandle"/> and <see cref="SafePipeHandle"/> are supported in this list.
519case SafeFileHandle:
567static void ValidateHandle(SafeFileHandle? handle, string paramName)
583internal static void ValidateInheritedHandles(SafeFileHandle? stdinHandle, SafeFileHandle? stdoutHandle,
584SafeFileHandle? stderrHandle, SafeHandle[]? inheritedHandles = null)
System.IO.FileSystem (1)
System.IO.FileSystem.AccessControl (17)
System\IO\FileSystemAclExtensions.cs (8)
69SafeFileHandle handle = fileStream.SafeFileHandle;
90SafeFileHandle handle = fileStream.SafeFileHandle;
178SafeFileHandle handle = CreateFileHandle(fileInfo.FullName, mode, rights, share, options, fileSecurity);
255private static unsafe SafeFileHandle CreateFileHandle(string fullPath, FileMode mode, FileSystemRights rights, FileShare share, FileOptions options, FileSecurity? security)
270SafeFileHandle handle;
289static SafeFileHandle CreateFileHandleInternal(string fullPath, FileMode mode, FileSystemRights rights, FileShare share, int flagsAndAttributes, Interop.Kernel32.SECURITY_ATTRIBUTES* secAttrs)
291SafeFileHandle handle;
303private static void ValidateFileHandle(SafeFileHandle handle, string fullPath)
System.IO.FileSystem.Primitives (1)
System.IO.FileSystem.Watcher (14)
System.IO.IsolatedStorage (1)
System.IO.MemoryMappedFiles (38)
_generated\0\LibraryImports.g.cs (13)
296internal static partial nint MMap(nint addr, ulong len, global::Interop.Sys.MemoryMappedProtections prot, global::Interop.Sys.MemoryMappedFlags flags, global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, long offset)
304global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
415internal static partial global::Microsoft.Win32.SafeHandles.SafeFileHandle Open(string filename, global::Interop.Sys.OpenFlags flags, int mode)
422global::Microsoft.Win32.SafeHandles.SafeFileHandle __retVal = default;
425global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
497internal static partial int FTruncate(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, long length)
505global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
564internal static partial global::Microsoft.Win32.SafeHandles.SafeFileHandle ShmOpen(string name, global::Interop.Sys.OpenFlags flags, int mode)
571global::Microsoft.Win32.SafeHandles.SafeFileHandle __retVal = default;
574global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
661internal static partial global::Microsoft.Win32.SafeHandles.SafeFileHandle MemfdCreate(string name, int isReadonly)
668global::Microsoft.Win32.SafeHandles.SafeFileHandle __retVal = default;
671global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
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 (9)
13private static void VerifyMemoryMappedFileAccess(MemoryMappedFileAccess access, long capacity, SafeFileHandle? fileHandle, long fileSize, out bool isRegularFile)
44SafeFileHandle? fileHandle, string? mapName,
157private static SafeFileHandle CreateSharedBackingObject(Interop.Sys.MemoryMappedProtections protections, long capacity, HandleInheritability inheritability)
165private static SafeFileHandle? CreateSharedBackingObjectUsingMemoryShmOpen(
184SafeFileHandle fd;
267private static SafeFileHandle CreateSharedBackingObjectUsingMemoryMemfdCreate(
273SafeFileHandle fd = Interop.Sys.MemfdCreate(GenerateMapName(), isReadonly);
306private static SafeFileHandle CreateSharedBackingObjectUsingFile(Interop.Sys.MemoryMappedProtections protections, long capacity, HandleInheritability inheritability)
318SafeFileHandle fileHandle = File.OpenHandle(path, FileMode.CreateNew, TranslateProtectionsToFileAccess(protections), share);
System.IO.Pipes (7)
System.Net.Sockets (15)
System\Net\Sockets\SocketAsyncContext.Unix.cs (3)
693public SafeFileHandle FileHandle = null!; // always set when constructed
2160public SocketError SendFile(SafeFileHandle fileHandle, long offset, long count, int timeout, out long bytesSent)
2190public SocketError SendFileAsync(SafeFileHandle fileHandle, long offset, long count, out long bytesSent, Action<long, SocketError> callback, CancellationToken cancellationToken = default)
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 (206)
_generated\2\LibraryImports.g.cs (27)
2108internal static partial int FChMod(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, int mode)
2116global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
2414internal static partial int CopyFile(global::Microsoft.Win32.SafeHandles.SafeFileHandle source, global::Microsoft.Win32.SafeHandles.SafeFileHandle destination, long sourceLength)
2423global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __destination_native__marshaller = new();
2424global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __source_native__marshaller = new();
2600internal static partial bool FileSystemSupportsLocking(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, global::Interop.Sys.LockOperations lockOperation, bool accessWrite)
2609global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
2643internal static partial int FLock(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, global::Interop.Sys.LockOperations operation)
2651global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
2710internal static partial int FSync(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd)
2718global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
2751internal static partial int FTruncate(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, long length)
2759global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
3425internal static partial long LSeek(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, long offset, global::Interop.Sys.SeekWhence whence)
3433global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
3615internal static partial nint MMap(nint addr, ulong len, global::Interop.Sys.MemoryMappedProtections prot, global::Interop.Sys.MemoryMappedFlags flags, global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, long offset)
3623global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
3716internal static partial global::Microsoft.Win32.SafeHandles.SafeFileHandle Open(string filename, global::Interop.Sys.OpenFlags flags, int mode)
3723global::Microsoft.Win32.SafeHandles.SafeFileHandle __retVal = default;
3726global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedOut __retVal_native__marshaller = new();
3813internal static partial int PosixFAdvise(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, long offset, long length, global::Interop.Sys.FileAdvice advice)
3820global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
3850internal static partial int FAllocate(global::Microsoft.Win32.SafeHandles.SafeFileHandle fd, long offset, long length)
3858global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __fd_native__marshaller = new();
5180internal static partial void SetKeypadXmit(global::Microsoft.Win32.SafeHandles.SafeFileHandle terminalHandle, string terminfoString)
5188global::System.Runtime.InteropServices.Marshalling.SafeHandleMarshaller<global::Microsoft.Win32.SafeHandles.SafeFileHandle>.ManagedToUnmanagedIn __terminalHandle_native__marshaller = new();
src\runtime\src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs (12)
107private static SafeFileHandle Open(string path, Interop.Sys.OpenFlags flags, int mode, bool failForSymlink, out bool wasSymlink,
112SafeFileHandle handle = Interop.Sys.Open(path, flags, mode);
180public static partial void CreateAnonymousPipe(out SafeFileHandle readHandle, out SafeFileHandle writeHandle, bool asyncRead, bool asyncWrite)
183SafeFileHandle tempReadHandle = new();
184SafeFileHandle tempWriteHandle = new();
225internal static SafeFileHandle OpenReadOnly(string fullPath, FileOptions options, out long fileLength, out UnixFileMode filePermissions)
227SafeFileHandle handle = Open(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read, options, preallocationSize: 0, DefaultCreateMode, out fileLength, out filePermissions, false, out _, null);
232internal static SafeFileHandle Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, UnixFileMode? unixCreateMode = null,
238internal static SafeFileHandle? OpenNoFollowSymlink(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, out bool wasSymlink, UnixFileMode? unixCreateMode = null,
244private static SafeFileHandle Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, UnixFileMode openPermissions,
251SafeFileHandle? safeFileHandle = null;
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\File.cs (50)
136/// 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.
138/// <param name="path">A relative or absolute path for the file that the current <see cref="SafeFileHandle" /> instance will encapsulate.</param>
144/// <param name="options">An object that describes optional <see cref="SafeFileHandle" /> parameters to use.</param>
165public static SafeFileHandle OpenHandle(string path, FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read,
170return SafeFileHandle.Open(Path.GetFullPath(path), mode, access, share, options, preallocationSize);
176/// <returns>A <see cref="SafeFileHandle"/> to the system's null device.</returns>
194public static SafeFileHandle OpenNullHandle()
196return SafeFileHandle.Open(NullDevicePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite, FileOptions.None, preallocationSize: 0);
216/// A <see cref="SafeFileHandle" /> to the file or directory for which to set the creation date and time information.
234public static void SetCreationTime(SafeFileHandle fileHandle, DateTime creationTime)
248/// A <see cref="SafeFileHandle" /> to the file or directory for which to set the creation date and time information.
266public static void SetCreationTimeUtc(SafeFileHandle fileHandle, DateTime creationTimeUtc)
279/// A <see cref="SafeFileHandle" /> to the file or directory for which to obtain creation date and time information.
291public static DateTime GetCreationTime(SafeFileHandle fileHandle)
304/// A <see cref="SafeFileHandle" /> to the file or directory for which to obtain creation date and time information.
316public static DateTime GetCreationTimeUtc(SafeFileHandle fileHandle)
329/// A <see cref="SafeFileHandle" /> to the file or directory for which to set the last access date and time information.
347public static void SetLastAccessTime(SafeFileHandle fileHandle, DateTime lastAccessTime)
360/// A <see cref="SafeFileHandle" /> to the file or directory for which to set the last access date and time information.
378public static void SetLastAccessTimeUtc(SafeFileHandle fileHandle, DateTime lastAccessTimeUtc)
391/// A <see cref="SafeFileHandle" /> to the file or directory for which to obtain last access date and time information.
403public static DateTime GetLastAccessTime(SafeFileHandle fileHandle)
416/// A <see cref="SafeFileHandle" /> to the file or directory for which to obtain last access date and time information.
428public static DateTime GetLastAccessTimeUtc(SafeFileHandle fileHandle)
441/// A <see cref="SafeFileHandle" /> to the file or directory for which to set the last write date and time information.
459public static void SetLastWriteTime(SafeFileHandle fileHandle, DateTime lastWriteTime)
472/// A <see cref="SafeFileHandle" /> to the file or directory for which to set the last write date and time information.
490public static void SetLastWriteTimeUtc(SafeFileHandle fileHandle, DateTime lastWriteTimeUtc)
503/// A <see cref="SafeFileHandle" /> to the file or directory for which to obtain last write date and time information.
515public static DateTime GetLastWriteTime(SafeFileHandle fileHandle)
528/// A <see cref="SafeFileHandle" /> to the file or directory for which to obtain last write date and time information.
540public static DateTime GetLastWriteTimeUtc(SafeFileHandle fileHandle)
553/// A <see cref="SafeFileHandle" /> to the file or directory for which the attributes are to be retrieved.
564public static FileAttributes GetAttributes(SafeFileHandle fileHandle)
577/// A <see cref="SafeFileHandle" /> to the file or directory for which <paramref name="fileAttributes"/> should be set.
590/// using the <see cref="SetAttributes(SafeFileHandle, FileAttributes)"/> method.
592public static void SetAttributes(SafeFileHandle fileHandle, FileAttributes fileAttributes)
616public static UnixFileMode GetUnixFileMode(SafeFileHandle fileHandle)
640public static void SetUnixFileMode(SafeFileHandle fileHandle, UnixFileMode mode)
724using (SafeFileHandle sfh = OpenHandle(path, FileMode.Open, FileAccess.Read, FileShare.Read, options))
790using SafeFileHandle sfh = OpenHandle(path, FileMode.Create, FileAccess.Write, FileShare.Read);
840using SafeFileHandle fileHandle = OpenHandle(path, FileMode.Append, FileAccess.Write, FileShare.Read);
885using SafeFileHandle fileHandle = OpenHandle(path, FileMode.Append, FileAccess.Write, FileShare.Read, FileOptions.Asynchronous);
1205SafeFileHandle sfh = OpenHandle(path, FileMode.Open, FileAccess.Read, FileShare.Read, options);
1225private static async Task<byte[]> InternalReadAllBytesAsync(SafeFileHandle sfh, int count, CancellationToken cancellationToken)
1248private static async Task<byte[]> InternalReadAllBytesUnknownLengthAsync(SafeFileHandle sfh, CancellationToken cancellationToken)
1316using SafeFileHandle sfh = OpenHandle(path, FileMode.Create, FileAccess.Write, FileShare.Read, FileOptions.Asynchronous);
1512private static unsafe byte[] ReadAllBytesUnknownLength(SafeFileHandle sfh)
1562using SafeFileHandle fileHandle = OpenHandle(path, mode, FileAccess.Write, FileShare.Read, FileOptions.None, GetPreallocationSize(mode, contents, encoding, preambleSize));
1618using SafeFileHandle fileHandle = OpenHandle(path, mode, FileAccess.Write, FileShare.Read, FileOptions.Asynchronous, GetPreallocationSize(mode, contents.Span, encoding, preambleSize));
src\runtime\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)
451internal UnixFileMode GetUnixFileMode(SafeFileHandle handle, bool continueOnError = false)
454private UnixFileMode GetUnixFileMode(SafeFileHandle? handle, ReadOnlySpan<char> path, bool continueOnError = false)
467internal void SetUnixFileMode(SafeFileHandle handle, UnixFileMode mode)
470private void SetUnixFileMode(SafeFileHandle? handle, string? path, UnixFileMode mode)
491internal void RefreshCaches(SafeFileHandle? handle, ReadOnlySpan<char> path)
551internal void EnsureCachesInitialized(SafeFileHandle? handle, ReadOnlySpan<char> path, bool continueOnError = false)
src\runtime\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\runtime\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 = true)
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\RandomAccess.Unix.cs (10)
22internal static unsafe void SetFileLength(SafeFileHandle handle, long length) =>
25internal static unsafe int ReadAtOffset(SafeFileHandle handle, Span<byte> buffer, long fileOffset)
58internal static unsafe long ReadScatterAtOffset(SafeFileHandle handle, IReadOnlyList<Memory<byte>> buffers, long fileOffset)
104internal static ValueTask<int> ReadAtOffsetAsync(SafeFileHandle handle, Memory<byte> buffer, long fileOffset, CancellationToken cancellationToken, OSFileStreamStrategy? strategy = null)
107private static ValueTask<long> ReadScatterAtOffsetAsync(SafeFileHandle handle, IReadOnlyList<Memory<byte>> buffers, long fileOffset, CancellationToken cancellationToken)
110internal static unsafe void WriteAtOffset(SafeFileHandle handle, ReadOnlySpan<byte> buffer, long fileOffset)
113internal static unsafe void WriteAtOffset(SafeFileHandle handle, ReadOnlySpan<byte> buffer, ref long fileOffset)
175internal static unsafe void WriteGatherAtOffset(SafeFileHandle handle, IReadOnlyList<ReadOnlyMemory<byte>> buffers, long fileOffset)
270internal static ValueTask WriteAtOffsetAsync(SafeFileHandle handle, ReadOnlyMemory<byte> buffer, long fileOffset, CancellationToken cancellationToken, OSFileStreamStrategy? strategy = null)
273private static ValueTask WriteGatherAtOffsetAsync(SafeFileHandle handle, IReadOnlyList<ReadOnlyMemory<byte>> buffers, long fileOffset, CancellationToken cancellationToken)
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\SharedMemoryManager.Unix.cs (14)
126private readonly SafeFileHandle _fileHandle;
131public SharedMemoryProcessDataHeader(SharedMemoryId id, SafeFileHandle fileHandle, SharedMemorySharedDataHeader* sharedDataHeader, nuint sharedDataTotalByteCount)
195SafeFileHandle fileHandle = SharedMemoryHelpers.CreateOrOpenFile(sharedMemoryFilePath, id, createIfNotExist, out bool createdFile);
420internal static SafeFileHandle CreateOrOpenFile(string sharedMemoryFilePath, SharedMemoryId id, bool createIfNotExist, out bool createdFile)
426SafeFileHandle fd = Interop.Sys.Open(sharedMemoryFilePath, Interop.Sys.OpenFlags.O_RDWR | Interop.Sys.OpenFlags.O_CLOEXEC, 0);
709internal static MemoryMappedFileHolder MemoryMapFile(SafeFileHandle fileHandle, nuint sharedDataTotalByteCount)
728internal static bool TryAcquireFileLock(SafeFileHandle sharedLockFileHandle, bool nonBlocking, bool exclusive = true)
772internal unsafe ref struct AutoReleaseFileLock(SafeFileHandle fd)
776public readonly SafeFileHandle FileHandle = fd;
800private SafeFileHandle? _creationDeletionLockFileHandle;
801private readonly Dictionary<uint, SafeFileHandle> _uidToFileHandleMap = [];
816SafeFileHandle? fd = id.IsUserScope ? GetUserScopeCreationDeletionLockFileHandle(id.Uid) : _creationDeletionLockFileHandle;
858SafeFileHandle? GetUserScopeCreationDeletionLockFileHandle(uint uid)
860_uidToFileHandleMap.TryGetValue(uid, out SafeFileHandle? fileHandle);
System.Runtime (1)
vbc (3)
VBCSCompiler (3)