This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2049 from janhenke/System.IO.FileSystem
Implement System.IO.FileSystem assembly on FreeBSD
- Loading branch information
Showing
6 changed files
with
105 additions
and
3 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/Common/src/Interop/FreeBSD/libc/Interop.PathConfNames.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class libc | ||
{ | ||
internal static class PathConfNames | ||
{ | ||
internal const int _PC_NAME_MAX = 4; | ||
internal const int _PC_PATH_MAX = 5; | ||
} | ||
|
||
internal static int DEFAULT_PC_NAME_MAX = 255; | ||
internal static int DEFAULT_PC_PATH_MAX = 1024; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
using ino_t = System.IntPtr; | ||
using off_t = System.Int64; // Assuming either 64-bit machine or _FILE_OFFSET_BITS == 64 | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class libc | ||
{ | ||
[DllImport(Libraries.Libc, SetLastError = true)] | ||
internal static extern IntPtr readdir(SafeDirHandle dirp); | ||
|
||
internal static unsafe DType GetDirEntType(IntPtr dirEnt) | ||
{ | ||
return ((dirent*)dirEnt)->d_type; | ||
} | ||
|
||
internal static unsafe string GetDirEntName(IntPtr dirEnt) | ||
{ | ||
return Marshal.PtrToStringAnsi((IntPtr)((dirent*)dirEnt)->d_name); | ||
} | ||
|
||
internal enum DType : byte | ||
{ | ||
DT_UNKNOWN = 0, | ||
DT_FIFO = 1, | ||
DT_CHR = 2, | ||
DT_DIR = 4, | ||
DT_BLK = 6, | ||
DT_REG = 8, | ||
DT_LNK = 10, | ||
DT_SOCK = 12, | ||
DT_WHT = 14 | ||
} | ||
|
||
#pragma warning disable 0649 // fields are assigned by P/Invoke call | ||
private unsafe struct dirent | ||
{ | ||
internal UInt32 d_fileno; | ||
internal UInt16 d_reclen; | ||
internal DType d_type; | ||
internal byte d_namlen; | ||
internal fixed byte d_name[256]; | ||
} | ||
#pragma warning restore 0649 | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.