+static bool CanReadICOOrCUR(wxInputStream *stream, wxUint16 resourceType)
+{
+ ICONDIR iconDir;
+ if ( !stream->Read(&iconDir, sizeof(iconDir)) ) // it's ok to modify the stream position here
+ {
+ return false;
+ }
+
+ return !iconDir.idReserved // reserved, must be 0
+ && wxUINT16_SWAP_ON_BE(iconDir.idType) == resourceType // either 1 or 2
+ && iconDir.idCount; // must contain at least one image
+}
+