@@ -318,8 +318,8 @@ public bool ShouldIgnore(string pattern, out bool result)
318
318
#region UNIX/LINUX
319
319
320
320
// Unix-based stat method
321
- [ LibraryImport ( "libc" , EntryPoint = "stat" , SetLastError = true ) ]
322
- private static unsafe partial int FileStat ( byte * path , out Stat buf ) ;
321
+ [ DllImport ( "libc" , CallingConvention = CallingConvention . Cdecl , EntryPoint = "stat" , SetLastError = true ) ]
322
+ private static extern unsafe int FileStat ( byte * path , out Stat buf ) ;
323
323
324
324
[ StructLayout ( LayoutKind . Sequential ) ]
325
325
private struct Stat
@@ -485,15 +485,15 @@ public bool ShouldIgnore()
485
485
}
486
486
487
487
// P/Invoke for opendir
488
- [ DllImport ( "libc" , EntryPoint = "opendir" , SetLastError = true ) ]
488
+ [ DllImport ( "libc" , CallingConvention = CallingConvention . Cdecl , EntryPoint = "opendir" , SetLastError = true ) ]
489
489
private static extern unsafe nint OpenDir ( byte * name ) ;
490
490
491
491
// P/Invoke for readdir
492
- [ DllImport ( "libc" , EntryPoint = "readdir" , SetLastError = true ) ]
492
+ [ DllImport ( "libc" , CallingConvention = CallingConvention . Cdecl , EntryPoint = "readdir" , SetLastError = true ) ]
493
493
private static extern unsafe DirEnt * ReadDir ( nint dir ) ;
494
494
495
495
// P/Invoke for closedir
496
- [ DllImport ( "libc" , EntryPoint = "closedir" , SetLastError = true ) ]
496
+ [ DllImport ( "libc" , CallingConvention = CallingConvention . Cdecl , EntryPoint = "closedir" , SetLastError = true ) ]
497
497
private static extern unsafe int CloseDir ( nint dir ) ;
498
498
499
499
public static IEnumerable < FileMetadata > EnumerateEntriesUnix ( string path , string pattern , SearchOption option )
@@ -603,8 +603,9 @@ private static void FileStat(StdWString str, out Stat stat)
603
603
#region OSX
604
604
605
605
// Unix-based stat method
606
- [ LibraryImport ( "libSystem.B.dylib" , EntryPoint = "stat" , SetLastError = true ) ]
607
- private static unsafe partial int OSXFileStat ( byte * path , out OSXStat buf ) ;
606
+
607
+ [ DllImport ( "libSystem.B.dylib" , CallingConvention = CallingConvention . Cdecl , EntryPoint = "stat" , SetLastError = true ) ]
608
+ private static extern unsafe int OSXFileStat ( byte * path , out OSXStat buf ) ;
608
609
609
610
[ StructLayout ( LayoutKind . Sequential ) ]
610
611
private struct OSXStat
@@ -759,15 +760,15 @@ public bool ShouldIgnore()
759
760
}
760
761
761
762
// P/Invoke for opendir
762
- [ DllImport ( "libSystem.B.dylib" , EntryPoint = "opendir" , SetLastError = true ) ]
763
+ [ DllImport ( "libSystem.B.dylib" , CallingConvention = CallingConvention . Cdecl , EntryPoint = "opendir" , SetLastError = true ) ]
763
764
private static extern unsafe nint OSXOpenDir ( byte * name ) ;
764
765
765
766
// P/Invoke for readdir
766
- [ DllImport ( "libSystem.B.dylib" , EntryPoint = "readdir" , SetLastError = true ) ]
767
+ [ DllImport ( "libSystem.B.dylib" , CallingConvention = CallingConvention . Cdecl , EntryPoint = "readdir" , SetLastError = true ) ]
767
768
private static extern unsafe OSXDirEnt * OSXReadDir ( nint dir ) ;
768
769
769
770
// P/Invoke for closedir
770
- [ DllImport ( "libSystem.B.dylib" , EntryPoint = "closedir" , SetLastError = true ) ]
771
+ [ DllImport ( "libSystem.B.dylib" , CallingConvention = CallingConvention . Cdecl , EntryPoint = "closedir" , SetLastError = true ) ]
771
772
private static extern unsafe int OSXCloseDir ( nint dir ) ;
772
773
773
774
public static IEnumerable < FileMetadata > EnumerateEntriesOSX ( string path , string pattern , SearchOption option )
@@ -790,7 +791,6 @@ public static IEnumerable<FileMetadata> EnumerateEntriesOSX(string path, string
790
791
if ( ! dirEnt . ShouldIgnore ( pattern , out var ignore ) )
791
792
{
792
793
var meta = OSXConvert ( dirEnt , dir ) ;
793
- Print ( meta ) ;
794
794
795
795
if ( ( meta . Attributes & FileAttributes . Directory ) != 0 && option == SearchOption . AllDirectories )
796
796
{
@@ -799,9 +799,7 @@ public static IEnumerable<FileMetadata> EnumerateEntriesOSX(string path, string
799
799
800
800
if ( ! ignore )
801
801
{
802
- Print ( meta ) ;
803
802
yield return meta ;
804
- Print ( meta ) ;
805
803
meta . Path . Release ( ) ;
806
804
}
807
805
}
@@ -814,11 +812,6 @@ public static IEnumerable<FileMetadata> EnumerateEntriesOSX(string path, string
814
812
walkStack . Release ( ) ;
815
813
}
816
814
817
- private static void Print ( FileMetadata meta )
818
- {
819
- Console . WriteLine ( $ "Print -> Ptr: { ( nint ) meta . Path . Data } ") ;
820
- }
821
-
822
815
private static nint OSXOpenDir ( StdString str )
823
816
{
824
817
return OSXOpenDir ( str . Data ) ;
@@ -845,10 +838,9 @@ private static FileMetadata OSXConvert(OSXDirEnt entry, StdString path)
845
838
str . Append ( entry . d_name , length ) ;
846
839
* ( str . Data + str . Size ) = '\0 ' ;
847
840
FileMetadata meta = new ( ) ;
841
+ meta . Path = str ;
848
842
849
843
OSXFileStat ( str , out var stat ) ;
850
-
851
- meta . Path = str ;
852
844
meta . CreationTime = stat . st_ctimespec ;
853
845
meta . LastAccessTime = stat . st_atimespec ;
854
846
meta . LastWriteTime = stat . st_mtimespec ;
0 commit comments