[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH 1/4] Pascal-RTL: tar: FileDone raussplitten



* Pascal-RTL: tar: Wenn eine Datei fertig behandelt ist, passiert immmr
  das gleiche, egal ob die jetzt übersprungen, in eine Datei oder in
  einen String entpackt worden ist. Also kommt das in eine gemeinsame
  Funktion.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/modules/pas/lib/tar/tar.pas |   41 +++++++++++++++++---------------------
 1 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/src/modules/pas/lib/tar/tar.pas b/src/modules/pas/lib/tar/tar.pas
index ca3b12b..abe3b28 100644
--- a/src/modules/pas/lib/tar/tar.pas
+++ b/src/modules/pas/lib/tar/tar.pas
@@ -31,6 +31,7 @@ type
         private
             procedure ReadNextBlock(buffer_offset: dword);
             function BufferIsZero: boolean;
+            procedure FileDone;
 
         private
             f: file;
@@ -165,6 +166,20 @@ begin
     end;
 end;
 
+procedure TTarArchive.FileDone;
+begin
+    // Header der naechsten Datei einlesen
+    ReadNextBlock(0);
+
+    // Zwei Leerbloecke bedeuten das Ende der Datei
+    if not end_of_archive and BufferIsZero() then begin
+        ReadNextBlock(0);
+        if not end_of_archive and BufferIsZero() then begin
+            end_of_archive := true;
+        end;
+    end;
+end;
+
 function TTarArchive.ExtractString(silent: boolean = false): string;
 var
     filename: String;
@@ -206,14 +221,7 @@ begin
         WriteLn(#13, '[', filename, '] ', size, '/', size, ' Bytes entpackt');
     end;
 
-    ReadNextBlock(0);
-
-    if not end_of_archive and BufferIsZero() then begin
-        ReadNextBlock(0);
-        if not end_of_archive and BufferIsZero() then begin
-            end_of_archive := true;
-        end;
-    end;
+    FileDone;
 
     ExtractString := target;
 end;
@@ -248,14 +256,8 @@ begin
     end;
     WriteLn(#13, '[', filename, '] ', size, '/', size, ' Bytes entpackt');
 
-    ReadNextBlock(0);
+    FileDone;
 
-    if not end_of_archive and BufferIsZero() then begin
-        ReadNextBlock(0);
-        if not end_of_archive and BufferIsZero() then begin
-            end_of_archive := true;
-        end;
-    end;
 end;
 
 procedure TTarArchive.SkipFile;
@@ -269,14 +271,7 @@ begin
         ReadNextBlock(0);
     end;
 
-    ReadNextBlock(0);
-
-    if not end_of_archive and BufferIsZero() then begin
-        ReadNextBlock(0);
-        if not end_of_archive and BufferIsZero() then begin
-            end_of_archive := true;
-        end;
-    end;
+    FileDone;
 end;
 
 end.
-- 
1.6.0.2