More corelib cleanup (dotnet/coreclr#26993)
[mono-project.git] / netcore / System.Private.CoreLib / shared / Interop / Windows / Kernel32 / Interop.CreateFile.cs
blob9ebac4f6640bd1fe332cdc5795cadd2102ef779f
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 using Microsoft.Win32.SafeHandles;
6 using System;
7 using System.IO;
8 using System.Runtime.InteropServices;
10 internal static partial class Interop
12 internal static partial class Kernel32
14 /// <summary>
15 /// WARNING: This method does not implicitly handle long paths. Use CreateFile.
16 /// </summary>
17 [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
18 private static extern SafeFileHandle CreateFilePrivate(
19 string lpFileName,
20 int dwDesiredAccess,
21 System.IO.FileShare dwShareMode,
22 ref SECURITY_ATTRIBUTES securityAttrs,
23 System.IO.FileMode dwCreationDisposition,
24 int dwFlagsAndAttributes,
25 IntPtr hTemplateFile);
27 internal static SafeFileHandle CreateFile(
28 string lpFileName,
29 int dwDesiredAccess,
30 System.IO.FileShare dwShareMode,
31 ref SECURITY_ATTRIBUTES securityAttrs,
32 System.IO.FileMode dwCreationDisposition,
33 int dwFlagsAndAttributes,
34 IntPtr hTemplateFile)
36 lpFileName = PathInternal.EnsureExtendedPrefixIfNeeded(lpFileName);
37 return CreateFilePrivate(lpFileName, dwDesiredAccess, dwShareMode, ref securityAttrs, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);