diff options
Diffstat (limited to 'src/mscorlib/src/System/IO/FileSystemEnumerable.cs')
-rw-r--r-- | src/mscorlib/src/System/IO/FileSystemEnumerable.cs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/mscorlib/src/System/IO/FileSystemEnumerable.cs b/src/mscorlib/src/System/IO/FileSystemEnumerable.cs index 0316de0f93..5e19fbed36 100644 --- a/src/mscorlib/src/System/IO/FileSystemEnumerable.cs +++ b/src/mscorlib/src/System/IO/FileSystemEnumerable.cs @@ -146,8 +146,10 @@ namespace System.IO private SearchOption searchOption; private String fullPath; private String normalizedSearchPath; - private int oldMode; - +#if !PLATFORM_UNIX + private int _oldMode; + private bool _setBackOldMode; +#endif internal FileSystemEnumerableIterator(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler<TSource> resultHandler, bool checkHost) { Contract.Requires(path != null); @@ -156,7 +158,9 @@ namespace System.IO Contract.Requires(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly); Contract.Requires(resultHandler != null); - oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS); +#if !PLATFORM_UNIX + _setBackOldMode = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out _oldMode); +#endif searchStack = new List<Directory.SearchData>(); @@ -284,7 +288,14 @@ namespace System.IO } finally { - Win32Native.SetErrorMode(oldMode); +#if !PLATFORM_UNIX + if (_setBackOldMode) + { + uint _ignore; + Interop.Kernel32.SetThreadErrorMode(_oldMode, out _ignore); + } +#endif + base.Dispose(disposing); } } |