Browse Source

+ TZipper: added support for zip file comments

git-svn-id: trunk@22285 -
nickysn 13 years ago
parent
commit
cb4dadb079
1 changed files with 5 additions and 1 deletions
  1. 5 1
      packages/paszlib/src/zipper.pp

+ 5 - 1
packages/paszlib/src/zipper.pp

@@ -306,6 +306,7 @@ Type
     FZipping    : Boolean;
     FZipping    : Boolean;
     FBufSize    : LongWord;
     FBufSize    : LongWord;
     FFileName   :  String;         { Name of resulting Zip file                 }
     FFileName   :  String;         { Name of resulting Zip file                 }
+    FFileComment: String;
     FFiles      : TStrings;
     FFiles      : TStrings;
     FInMemSize  : Integer;
     FInMemSize  : Integer;
     FOutStream  : TStream;
     FOutStream  : TStream;
@@ -349,6 +350,7 @@ Type
     Property OnStartFile : TOnStartFileEvent Read FOnStartFile Write FOnStartFile;
     Property OnStartFile : TOnStartFileEvent Read FOnStartFile Write FOnStartFile;
     Property OnEndFile : TOnEndOfFileEvent Read FOnEndOfFile Write FOnEndOfFile;
     Property OnEndFile : TOnEndOfFileEvent Read FOnEndOfFile Write FOnEndOfFile;
     Property FileName : String Read FFileName Write SetFileName;
     Property FileName : String Read FFileName Write SetFileName;
+    Property FileComment: String Read FFileComment Write FFileComment;
     // Deprecated. Use Entries.AddFileEntry(FileName) or Entries.AddFileEntries(List) instead.
     // Deprecated. Use Entries.AddFileEntry(FileName) or Entries.AddFileEntries(List) instead.
     Property Files : TStrings Read FFiles; deprecated;
     Property Files : TStrings Read FFiles; deprecated;
     Property InMemSize : Integer Read FInMemSize Write FInMemSize;
     Property InMemSize : Integer Read FInMemSize Write FInMemSize;
@@ -1359,8 +1361,10 @@ Begin
      Total_Entries := ACount;
      Total_Entries := ACount;
      Central_Dir_Size := FOutStream.Size-CenDirPos;
      Central_Dir_Size := FOutStream.Size-CenDirPos;
      Start_Disk_Offset := CenDirPos;
      Start_Disk_Offset := CenDirPos;
-     ZipFile_Comment_Length := 0;
+     ZipFile_Comment_Length := Length(FFileComment);
      FOutStream.WriteBuffer({$IFDEF FPC_BIG_ENDIAN}SwapECD{$ENDIF}(EndHdr), SizeOf(EndHdr));
      FOutStream.WriteBuffer({$IFDEF FPC_BIG_ENDIAN}SwapECD{$ENDIF}(EndHdr), SizeOf(EndHdr));
+     if Length(FFileComment) > 0 then
+       FOutStream.WriteBuffer(FFileComment[1],Length(FFileComment));
      end;
      end;
 end;
 end;