@@ -1166,27 +1166,32 @@ public static string ParseSymLink(string path)
1166
1166
}
1167
1167
1168
1168
// 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 )
1170
1170
{
1171
1171
Win32PInvoke . WIN32_FIND_STREAM_DATA findStreamData = new Win32PInvoke . WIN32_FIND_STREAM_DATA ( ) ;
1172
- IntPtr hFile = Win32PInvoke . FindFirstStreamW ( path , Win32PInvoke . StreamInfoLevels . FindStreamInfoStandard , findStreamData , 0 ) ;
1173
1172
1174
- if ( hFile . ToInt64 ( ) != - 1 )
1173
+ fixed ( char * pszStr = path )
1175
1174
{
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 )
1177
1178
{
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
1182
1180
{
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
+ }
1184
1188
}
1185
- }
1186
- while ( Win32PInvoke . FindNextStreamW ( hFile , findStreamData ) ) ;
1189
+ while ( PInvoke . FindNextStream ( hFile , findStreamData ) ) ;
1187
1190
1188
- Win32PInvoke . FindClose ( hFile ) ;
1191
+ PInvoke . FindClose ( ( Windows . Win32 . Foundation . HANDLE ) hFile ) ;
1192
+ }
1189
1193
}
1194
+
1190
1195
}
1191
1196
1192
1197
public static bool GetWin32FindDataForPath ( string targetPath , out Win32PInvoke . WIN32_FIND_DATA findData )
0 commit comments