diff options
author | Jan Kotas <jkotas@microsoft.com> | 2017-08-25 03:13:27 +0300 |
---|---|---|
committer | Dan Moseley <danmose@microsoft.com> | 2017-08-25 03:13:27 +0300 |
commit | 94b19a4a2405c9fabaf6564cb49cbc4b0957ac6c (patch) | |
tree | c333fcfe6839bd62375daf0669589a954758f565 /src/System.IO.FileSystem | |
parent | a534c0ebbd3c5741f97590ece32f1b31645f0994 (diff) |
Make DisableMediaInsertionPrompt to be private struct to match CoreLib (#23507)
Diffstat (limited to 'src/System.IO.FileSystem')
3 files changed, 10 insertions, 8 deletions
diff --git a/src/System.IO.FileSystem/src/System/IO/DisableMediaInsertionPrompt.cs b/src/System.IO.FileSystem/src/System/IO/DisableMediaInsertionPrompt.cs index ca6261e8e7..aa10e8d883 100644 --- a/src/System.IO.FileSystem/src/System/IO/DisableMediaInsertionPrompt.cs +++ b/src/System.IO.FileSystem/src/System/IO/DisableMediaInsertionPrompt.cs @@ -14,14 +14,16 @@ namespace System.IO /// prompt won't happen. You have to have had media in at least once to get /// the file system to load and then have removed it. /// </remarks> - public sealed class DisableMediaInsertionPrompt : IDisposable + internal struct DisableMediaInsertionPrompt : IDisposable { private bool _disableSuccess; private uint _oldMode; - public DisableMediaInsertionPrompt() + public static DisableMediaInsertionPrompt Create() { - _disableSuccess = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out _oldMode); + DisableMediaInsertionPrompt prompt = new DisableMediaInsertionPrompt(); + prompt._disableSuccess = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out prompt._oldMode); + return prompt; } public void Dispose() diff --git a/src/System.IO.FileSystem/src/System/IO/Win32FileSystem.cs b/src/System.IO.FileSystem/src/System/IO/Win32FileSystem.cs index 0d0b671b99..63ea6e1558 100644 --- a/src/System.IO.FileSystem/src/System/IO/Win32FileSystem.cs +++ b/src/System.IO.FileSystem/src/System/IO/Win32FileSystem.cs @@ -223,7 +223,7 @@ namespace System.IO // Neither GetFileAttributes or FindFirstFile like trailing separators path = path.TrimEnd(PathHelpers.DirectorySeparatorChars); - using (new DisableMediaInsertionPrompt()) + using (DisableMediaInsertionPrompt.Create()) { if (!Interop.Kernel32.GetFileAttributesEx(path, Interop.Kernel32.GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard, ref data)) { diff --git a/src/System.IO.FileSystem/src/System/IO/Win32FileSystemEnumerable.cs b/src/System.IO.FileSystem/src/System/IO/Win32FileSystemEnumerable.cs index 953c348b6e..ea46672197 100644 --- a/src/System.IO.FileSystem/src/System/IO/Win32FileSystemEnumerable.cs +++ b/src/System.IO.FileSystem/src/System/IO/Win32FileSystemEnumerable.cs @@ -161,7 +161,7 @@ namespace System.IO Interop.Kernel32.WIN32_FIND_DATA data = new Interop.Kernel32.WIN32_FIND_DATA(); - using (new DisableMediaInsertionPrompt()) + using (DisableMediaInsertionPrompt.Create()) { // Open a Find handle _hnd = Interop.Kernel32.FindFirstFile(searchPath, ref data); @@ -302,7 +302,7 @@ namespace System.IO // Execute searchCriteria against the current directory string searchPath = Path.Combine(_searchData.FullPath, _searchCriteria); - using (new DisableMediaInsertionPrompt()) + using (DisableMediaInsertionPrompt.Create()) { // Open a Find handle _hnd = Interop.Kernel32.FindFirstFile(searchPath, ref data); @@ -343,7 +343,7 @@ namespace System.IO { if (_hnd != null) { - using (new DisableMediaInsertionPrompt()) + using (DisableMediaInsertionPrompt.Create()) { // Keep asking for more matching files/dirs, add it to the list while (Interop.Kernel32.FindNextFile(_hnd, ref data)) @@ -420,7 +420,7 @@ namespace System.IO Interop.Kernel32.WIN32_FIND_DATA data = new Interop.Kernel32.WIN32_FIND_DATA(); try { - using (new DisableMediaInsertionPrompt()) + using (DisableMediaInsertionPrompt.Create()) { // Get all files and dirs hnd = Interop.Kernel32.FindFirstFile(searchPath, ref data); |