@@ -318,8 +318,8 @@ public bool ShouldIgnore(string pattern, out bool result)
318318 #region UNIX/LINUX
319319
320320 // 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 ) ;
323323
324324 [ StructLayout ( LayoutKind . Sequential ) ]
325325 private struct Stat
@@ -485,15 +485,15 @@ public bool ShouldIgnore()
485485 }
486486
487487 // P/Invoke for opendir
488- [ DllImport ( "libc" , EntryPoint = "opendir" , SetLastError = true ) ]
488+ [ DllImport ( "libc" , CallingConvention = CallingConvention . Cdecl , EntryPoint = "opendir" , SetLastError = true ) ]
489489 private static extern unsafe nint OpenDir ( byte * name ) ;
490490
491491 // P/Invoke for readdir
492- [ DllImport ( "libc" , EntryPoint = "readdir" , SetLastError = true ) ]
492+ [ DllImport ( "libc" , CallingConvention = CallingConvention . Cdecl , EntryPoint = "readdir" , SetLastError = true ) ]
493493 private static extern unsafe DirEnt * ReadDir ( nint dir ) ;
494494
495495 // P/Invoke for closedir
496- [ DllImport ( "libc" , EntryPoint = "closedir" , SetLastError = true ) ]
496+ [ DllImport ( "libc" , CallingConvention = CallingConvention . Cdecl , EntryPoint = "closedir" , SetLastError = true ) ]
497497 private static extern unsafe int CloseDir ( nint dir ) ;
498498
499499 public static IEnumerable < FileMetadata > EnumerateEntriesUnix ( string path , string pattern , SearchOption option )
@@ -603,8 +603,9 @@ private static void FileStat(StdWString str, out Stat stat)
603603 #region OSX
604604
605605 // 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 ) ;
608609
609610 [ StructLayout ( LayoutKind . Sequential ) ]
610611 private struct OSXStat
@@ -759,15 +760,15 @@ public bool ShouldIgnore()
759760 }
760761
761762 // 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 ) ]
763764 private static extern unsafe nint OSXOpenDir ( byte * name ) ;
764765
765766 // 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 ) ]
767768 private static extern unsafe OSXDirEnt * OSXReadDir ( nint dir ) ;
768769
769770 // 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 ) ]
771772 private static extern unsafe int OSXCloseDir ( nint dir ) ;
772773
773774 public static IEnumerable < FileMetadata > EnumerateEntriesOSX ( string path , string pattern , SearchOption option )
@@ -790,7 +791,6 @@ public static IEnumerable<FileMetadata> EnumerateEntriesOSX(string path, string
790791 if ( ! dirEnt . ShouldIgnore ( pattern , out var ignore ) )
791792 {
792793 var meta = OSXConvert ( dirEnt , dir ) ;
793- Print ( meta ) ;
794794
795795 if ( ( meta . Attributes & FileAttributes . Directory ) != 0 && option == SearchOption . AllDirectories )
796796 {
@@ -799,9 +799,7 @@ public static IEnumerable<FileMetadata> EnumerateEntriesOSX(string path, string
799799
800800 if ( ! ignore )
801801 {
802- Print ( meta ) ;
803802 yield return meta ;
804- Print ( meta ) ;
805803 meta . Path . Release ( ) ;
806804 }
807805 }
@@ -814,11 +812,6 @@ public static IEnumerable<FileMetadata> EnumerateEntriesOSX(string path, string
814812 walkStack . Release ( ) ;
815813 }
816814
817- private static void Print ( FileMetadata meta )
818- {
819- Console . WriteLine ( $ "Print -> Ptr: { ( nint ) meta . Path . Data } ") ;
820- }
821-
822815 private static nint OSXOpenDir ( StdString str )
823816 {
824817 return OSXOpenDir ( str . Data ) ;
@@ -845,10 +838,9 @@ private static FileMetadata OSXConvert(OSXDirEnt entry, StdString path)
845838 str . Append ( entry . d_name , length ) ;
846839 * ( str . Data + str . Size ) = '\0 ' ;
847840 FileMetadata meta = new ( ) ;
841+ meta . Path = str ;
848842
849843 OSXFileStat ( str , out var stat ) ;
850-
851- meta . Path = str ;
852844 meta . CreationTime = stat . st_ctimespec ;
853845 meta . LastAccessTime = stat . st_atimespec ;
854846 meta . LastWriteTime = stat . st_mtimespec ;
0 commit comments