OSDN Git Service

PATCH: [ 872413 ] UnpackDFM TestStreamFormat - Submitted by Michael Richter
authorKimmo Varis <kimmov@gmail.com>
Sun, 18 Jan 2004 19:01:14 +0000 (19:01 +0000)
committerKimmo Varis <kimmov@gmail.com>
Sun, 18 Jan 2004 19:01:14 +0000 (19:01 +0000)
Plugins/dlls/UnpackDFM.dll
Plugins/src_Delphi/UnpackDFM/UnpackDFMLib_TLB.pas
Plugins/src_Delphi/UnpackDFM/WinMergeUnit.pas
Src/readme.txt

index 4244b5d..fd07fbf 100644 (file)
Binary files a/Plugins/dlls/UnpackDFM.dll and b/Plugins/dlls/UnpackDFM.dll differ
index bd566dd..3be5d9f 100644 (file)
@@ -24,7 +24,8 @@ unit UnpackDFMLib_TLB;
 
 interface
 
-uses Windows, ActiveX, Classes, Graphics, OleCtrls, StdVCL;
+uses
+  Windows{, ActiveX, Classes, Graphics, OleCtrls, StdVCL};
 
 // *********************************************************************//
 // GUIDS declared in the TypeLibrary. Following prefixes are used:      //
index 1bd8e61..7122374 100644 (file)
@@ -3,7 +3,7 @@ unit WinMergeUnit;
 interface
 
 uses
-  ComObj, ActiveX, UnpackDFMLib_TLB;
+  ComObj, UnpackDFMLib_TLB;
 
 type
   TWinMergeScript = class(TAutoObject, IWinMergeScript)
@@ -20,7 +20,8 @@ type
 
 implementation
 
-uses ComServ, SysUtils, Dialogs, Classes;
+uses
+  ComServ, SysUtils, Classes;
 
 function TWinMergeScript.Get_PluginDescription : WideString;
 begin
@@ -80,29 +81,38 @@ end;
 // ------------------------------------------------------------------
 function TWinMergeScript.UnpackFile(const fileSrc, fileDst : WideString;
   var pChanged : WordBool; var pSubcode : Integer) : WordBool;
+const
+  FilerSignature = integer($30465054);           // 'TPF0'
+  ResSignature = integer($00000AFF);             // FF 04 00
 var
-  src : TFileStream;
-  dst : TFileStream;
+  src: TFileStream;
+  dst: TFileStream;
+  Signature: Integer;
 begin
+  result := false;
+  pChanged := false;
   try
 
     src := TFileStream.Create(fileSrc, fmOpenRead);
     try
-      dst := TFileStream.Create(fileDst, fmCreate);
-      try
-        ObjectResourceToText(src, dst);
-      finally
-        dst.Free;
+      //if (TestStreamFormat(src) = sofBinary) then begin
+      src.Read(Signature, SizeOf(Signature));
+      if (Signature = FilerSignature) or (Signature and $00FFFFFF = ResSignature) then begin
+        src.Seek(0, soFromBeginning);
+        dst := TFileStream.Create(fileDst, fmCreate);
+        try
+          ObjectResourceToText(src, dst);
+          pChanged := true;
+        finally
+          dst.Free;
+        end;
       end;
+      result := true;
     finally
       src.Free;
     end;
 
-    pChanged := true;
-    result := true;
   except
-    pChanged := false;
-    result := false;
   end;
 end;
 
index 1860783..8706512 100644 (file)
@@ -3,6 +3,11 @@
   src new files: WMGotoDlg.h WMGotoDlg.cpp
   src: Merge.dsp Merge.rc MergeEditView.h MergeEditView.cpp resource.h
   src/Languages: *.rc resource.h
+ PATCH: [ 872413 ] UnpackDFM TestStreamFormat
+  Submitted by Michael Richter
+  Plugins/Delphi/UnpackFDM: UnpackFDM.dpr UnpackFDMLib_TLB.pas
+   WinMergeUnit.pas
+  Plugins/dlls: UnpackFDM.dll
 
 2004-01-17 Kimmo
  PATCH: [ 871789 ] Add "Copy to..." items to dirview context menu