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.
6 using System
.Runtime
.InteropServices
;
8 internal static partial class Interop
10 internal static partial class Sys
12 [DllImport(Libraries
.SystemNative
, EntryPoint
= "SystemNative_OpenDir", SetLastError
= true)]
13 internal static extern IntPtr
OpenDir_native(string path
);
15 [DllImport(Libraries
.SystemNative
, EntryPoint
= "SystemNative_ReadDirR", SetLastError
= false)]
16 internal static extern unsafe int ReadDirR_native(IntPtr dir
, byte* buffer
, int bufferSize
, out DirectoryEntry outputEntry
);
18 [DllImport(Libraries
.SystemNative
, EntryPoint
= "SystemNative_CloseDir", SetLastError
= true)]
19 internal static extern int CloseDir_native(IntPtr dir
);
21 internal static IntPtr
OpenDir (string path
) {
24 result
= OpenDir_native (path
);
25 } while (result
== IntPtr
.Zero
&& Marshal
.GetLastWin32Error () == (int) Interop
.Error
.EINTR
);
29 internal static int CloseDir (IntPtr dir
) {
32 result
= CloseDir_native (dir
);
33 } while (result
< 0 && Marshal
.GetLastWin32Error () == (int) Interop
.Error
.EINTR
);
37 internal static unsafe int ReadDirR (IntPtr dir
, byte* buffer
, int bufferSize
, out DirectoryEntry outputEntry
) {
40 result
= ReadDirR_native (dir
, buffer
, bufferSize
, out outputEntry
);
41 } while (result
== (int) Interop
.Error
.EINTR
);