diff options
author | Jan Kotas <jkotas@microsoft.com> | 2017-03-18 19:41:39 -0700 |
---|---|---|
committer | dotnet-bot <dotnet-bot@microsoft.com> | 2017-03-20 19:06:26 +0000 |
commit | 40fee095de80676ffb6e60bd2e9d38d85bfa40b3 (patch) | |
tree | 7837012fda60e7bbefe2b05d9d2bccefb7198a99 | |
parent | 8ada92875cba27ab5336dfad88f2ae9ffc101dad (diff) | |
download | coreclr-40fee095de80676ffb6e60bd2e9d38d85bfa40b3.tar.gz coreclr-40fee095de80676ffb6e60bd2e9d38d85bfa40b3.tar.bz2 coreclr-40fee095de80676ffb6e60bd2e9d38d85bfa40b3.zip |
Fix FileStream for ProjectN
[tfs-changeset: 1651325]
-rw-r--r-- | src/mscorlib/shared/Interop/Windows/Kernel32/Interop.CreateFile2.cs | 8 | ||||
-rw-r--r-- | src/mscorlib/shared/System/IO/FileStream.WinRT.cs | 15 |
2 files changed, 13 insertions, 10 deletions
diff --git a/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.CreateFile2.cs b/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.CreateFile2.cs index d8cfabddac..0909d3a6c8 100644 --- a/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.CreateFile2.cs +++ b/src/mscorlib/shared/Interop/Windows/Kernel32/Interop.CreateFile2.cs @@ -11,20 +11,20 @@ internal partial class Interop internal partial class Kernel32 { [DllImport(Libraries.Kernel32, EntryPoint = "CreateFile2", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)] - internal static extern SafeFileHandle CreateFile2( + internal static extern unsafe SafeFileHandle CreateFile2( string lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, System.IO.FileMode dwCreationDisposition, - ref CREATEFILE2_EXTENDED_PARAMETERS parameters); + CREATEFILE2_EXTENDED_PARAMETERS* pCreateExParams); - internal struct CREATEFILE2_EXTENDED_PARAMETERS + internal unsafe struct CREATEFILE2_EXTENDED_PARAMETERS { internal uint dwSize; internal uint dwFileAttributes; internal uint dwFileFlags; internal uint dwSecurityQosFlags; - internal IntPtr lpSecurityAttributes; + internal SECURITY_ATTRIBUTES* lpSecurityAttributes; internal IntPtr hTemplateFile; } } diff --git a/src/mscorlib/shared/System/IO/FileStream.WinRT.cs b/src/mscorlib/shared/System/IO/FileStream.WinRT.cs index df5e9966b3..062b160b57 100644 --- a/src/mscorlib/shared/System/IO/FileStream.WinRT.cs +++ b/src/mscorlib/shared/System/IO/FileStream.WinRT.cs @@ -9,7 +9,7 @@ namespace System.IO { public partial class FileStream : Stream { - private SafeFileHandle OpenHandle(FileMode mode, FileShare share, FileOptions options) + private unsafe SafeFileHandle OpenHandle(FileMode mode, FileShare share, FileOptions options) { Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = GetSecAttrs(share); @@ -26,14 +26,16 @@ namespace System.IO mode = FileMode.OpenOrCreate; Interop.Kernel32.CREATEFILE2_EXTENDED_PARAMETERS parameters = new Interop.Kernel32.CREATEFILE2_EXTENDED_PARAMETERS(); + parameters.dwSize = (uint)sizeof(Interop.Kernel32.CREATEFILE2_EXTENDED_PARAMETERS); parameters.dwFileFlags = (uint)options; + parameters.lpSecurityAttributes = &secAttrs; SafeFileHandle fileHandle = Interop.Kernel32.CreateFile2( lpFileName: _path, dwDesiredAccess: fAccess, dwShareMode: share, dwCreationDisposition: mode, - parameters: ref parameters); + pCreateExParams: ¶meters); fileHandle.IsAsync = _useAsyncIO; @@ -55,21 +57,22 @@ namespace System.IO return fileHandle; } +#if PROJECTN // TODO: These internal methods should be removed once we start consuming updated CoreFX builds - internal static FileStream InternalOpen(string path, int bufferSize = 4096, bool useAsync = true) + public static FileStream InternalOpen(string path, int bufferSize = 4096, bool useAsync = true) { return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize, useAsync); } - internal static FileStream InternalCreate(string path, int bufferSize = 4096, bool useAsync = true) + public static FileStream InternalCreate(string path, int bufferSize = 4096, bool useAsync = true) { return new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, bufferSize, useAsync); } - internal static FileStream InternalAppend(string path, int bufferSize = 4096, bool useAsync = true) + public static FileStream InternalAppend(string path, int bufferSize = 4096, bool useAsync = true) { return new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Read, bufferSize, useAsync); } - +#endif } } |