@@ -1166,27 +1166,32 @@ public static string ParseSymLink(string path)
11661166 }
11671167
11681168 // https://stackoverflow.com/a/7988352
1169- public static IEnumerable < ( string Name , long Size ) > GetAlternateStreams ( string path )
1169+ public static unsafe IEnumerable < ( string Name , long Size ) > GetAlternateStreams ( string path )
11701170 {
11711171 Win32PInvoke . WIN32_FIND_STREAM_DATA findStreamData = new Win32PInvoke . WIN32_FIND_STREAM_DATA ( ) ;
1172- IntPtr hFile = Win32PInvoke . FindFirstStreamW ( path , Win32PInvoke . StreamInfoLevels . FindStreamInfoStandard , findStreamData , 0 ) ;
11731172
1174- if ( hFile . ToInt64 ( ) != - 1 )
1173+ fixed ( char * pszStr = path )
11751174 {
1176- do
1175+ FindCloseSafeHandle hFile = PInvoke . FindFirstStream ( new ( pszStr ) , Windows . Win32 . Storage . FileSystem . STREAM_INFO_LEVELS . FindStreamInfoStandard , findStreamData , 0 ) ;
1176+
1177+ if ( hFile . DangerousGetHandle ( ) . ToInt64 ( ) != - 1 )
11771178 {
1178- // The documentation for FindFirstStreamW says that it is always a ::$DATA
1179- // stream type, but FindNextStreamW doesn't guarantee that for subsequent
1180- // streams so we check to make sure
1181- if ( findStreamData . cStreamName . EndsWith ( ":$DATA" ) && findStreamData . cStreamName != "::$DATA" )
1179+ do
11821180 {
1183- yield return ( findStreamData . cStreamName , findStreamData . StreamSize ) ;
1181+ // The documentation for FindFirstStreamW says that it is always a ::$DATA
1182+ // stream type, but FindNextStreamW doesn't guarantee that for subsequent
1183+ // streams so we check to make sure
1184+ if ( findStreamData . cStreamName . EndsWith ( ":$DATA" ) && findStreamData . cStreamName != "::$DATA" )
1185+ {
1186+ yield return ( findStreamData . cStreamName , findStreamData . StreamSize ) ;
1187+ }
11841188 }
1185- }
1186- while ( Win32PInvoke . FindNextStreamW ( hFile , findStreamData ) ) ;
1189+ while ( PInvoke . FindNextStream ( hFile , findStreamData ) ) ;
11871190
1188- Win32PInvoke . FindClose ( hFile ) ;
1191+ PInvoke . FindClose ( ( Windows . Win32 . Foundation . HANDLE ) hFile ) ;
1192+ }
11891193 }
1194+
11901195 }
11911196
11921197 public static bool GetWin32FindDataForPath ( string targetPath , out Win32PInvoke . WIN32_FIND_DATA findData )
0 commit comments