|
@@ -2727,7 +2727,29 @@ begin
|
|
|
Output.FixupResourceHeader(FixupInfo); // Insert real resource data size
|
|
|
end;
|
|
|
|
|
|
+function TestStreamFormat(const Stream: TStream): TStreamOriginalFormat;
|
|
|
|
|
|
+const
|
|
|
+ StartChars = [#9, #10, #13, #11, 'o', 'O','i','I',' '];
|
|
|
+
|
|
|
+var
|
|
|
+ aPos: Int64;
|
|
|
+ Sig: Packed Array[0..3] of byte;
|
|
|
+ IntSig : Longint absolute sig;
|
|
|
+
|
|
|
+begin
|
|
|
+ Result:=sofUnknown;
|
|
|
+ aPos:=Stream.Position;
|
|
|
+ IntSig:=0;
|
|
|
+ Stream.Read(Sig,SizeOf(Sig));
|
|
|
+ Stream.Seek(aPos,soBeginning);
|
|
|
+ if (Sig[0]=$FF) or (IntSig=LongInt(FilerSignature)) or (IntSig=LongInt(FilerSignature1)) or (IntSig=0) then
|
|
|
+ Result:=sofBinary
|
|
|
+ else if (AnsiChar(Sig[0]) in StartChars) then
|
|
|
+ Result:=sofText
|
|
|
+ else if (Sig[1]=$BF) and (Sig[2]=$BB) and (Sig[3]=$EF) then
|
|
|
+ Result:=sofUTF8Text;
|
|
|
+end;
|
|
|
|
|
|
{ Utility routines }
|
|
|
|