mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Capability to create .zipx archives
This commit is contained in:
parent
5b7c954ea6
commit
e2f61890f3
4 changed files with 135 additions and 11 deletions
|
|
@ -525,7 +525,7 @@ begin
|
|||
if Result = atUnknown then begin
|
||||
{ Guess archive type based on it's extension }
|
||||
Ext := UpperCase(ExtractFileExt(FN));
|
||||
if (Ext = '.ZIP') or (Ext = '.JAR') then
|
||||
if (Ext = '.ZIP') or (Ext = '.JAR') or (Ext = '.ZIPX') then
|
||||
Result := atZip
|
||||
else if (Ext = '.EXE') then
|
||||
Result := atSelfExtZip
|
||||
|
|
|
|||
109
plugins/wcx/zip/fparchive/abxzprc.pas
Normal file
109
plugins/wcx/zip/fparchive/abxzprc.pas
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
(* ***** BEGIN LICENSE BLOCK *****
|
||||
* Compress item to .zipx archive
|
||||
*
|
||||
* Copyright (C) 2015-2016 Alexander Koblov (alexx2000@mail.ru)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** *)
|
||||
|
||||
{**********************************************************}
|
||||
{* ABBREVIA: AbXzPrc.pas *}
|
||||
{**********************************************************}
|
||||
{* ABBREVIA: TZipHashStream class *}
|
||||
{**********************************************************}
|
||||
|
||||
unit AbXzPrc;
|
||||
|
||||
{$mode delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BufStream, AbZipTyp, AbArcTyp;
|
||||
|
||||
type
|
||||
|
||||
{ TZipHashStream }
|
||||
|
||||
TZipHashStream = class(TReadBufStream)
|
||||
private
|
||||
FSize: Int64;
|
||||
FHash: LongInt;
|
||||
FOnProgress: TAbProgressEvent;
|
||||
public
|
||||
constructor Create(ASource : TStream); reintroduce;
|
||||
function Read(var ABuffer; ACount : LongInt) : Integer; override;
|
||||
property OnProgress : TAbProgressEvent read FOnProgress write FOnProgress;
|
||||
property Hash: LongInt read FHash;
|
||||
end;
|
||||
|
||||
procedure DoCompressXz(Archive : TAbZipArchive; Item : TAbZipItem; OutStream, InStream : TStream);
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
AbXz, AbDfBase, AbExcept;
|
||||
|
||||
procedure DoCompressXz(Archive : TAbZipArchive; Item : TAbZipItem; OutStream, InStream : TStream);
|
||||
var
|
||||
ASource: TZipHashStream;
|
||||
LzmaCompression: TLzmaCompression;
|
||||
begin
|
||||
Item.CompressionMethod := cmXz;
|
||||
ASource := TZipHashStream.Create(InStream);
|
||||
try
|
||||
ASource.OnProgress := Archive.OnProgress;
|
||||
LzmaCompression := TLzmaCompression.Create(ASource, OutStream);
|
||||
try
|
||||
LzmaCompression.Code(Item.UncompressedSize);
|
||||
finally
|
||||
LzmaCompression.Free;
|
||||
end;
|
||||
Item.CRC32 := not ASource.Hash;
|
||||
finally
|
||||
ASource.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TZipHashStream }
|
||||
|
||||
constructor TZipHashStream.Create(ASource: TStream);
|
||||
begin
|
||||
FHash := -1;
|
||||
FSize := ASource.Size;
|
||||
inherited Create(ASource);
|
||||
end;
|
||||
|
||||
function TZipHashStream.Read(var ABuffer; ACount: LongInt): Integer;
|
||||
var
|
||||
Abort: Boolean = False;
|
||||
begin
|
||||
Result := inherited Read(ABuffer, ACount);
|
||||
AbUpdateCRCBuffer(FHash, ABuffer, Result);
|
||||
if Assigned(FOnProgress) then
|
||||
begin
|
||||
FOnProgress(GetPosition * 100 div FSize, Abort);
|
||||
if Abort then raise EAbUserAbort.Create;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
|
@ -68,6 +68,7 @@ uses
|
|||
AbDfBase,
|
||||
AbDfEnc,
|
||||
AbSpanSt,
|
||||
AbXzPrc,
|
||||
DCClassesUtf8;
|
||||
|
||||
|
||||
|
|
@ -210,6 +211,9 @@ begin
|
|||
try
|
||||
if InStream.Size > 0 then begin
|
||||
|
||||
if SameText(ExtractFileExt(Sender.ArchiveName), '.zipx') then
|
||||
DoCompressXz(ZipArchive, Item, DestStrm, InStream)
|
||||
else
|
||||
{ determine how to store Item based on specified CompressionMethodToUse }
|
||||
case ZipArchive.CompressionMethodToUse of
|
||||
smDeflated : begin
|
||||
|
|
|
|||
|
|
@ -369,10 +369,10 @@ Index: AbBrowse.pas
|
|||
+ AbXzTyp,
|
||||
+ DCOSUtils,
|
||||
+ DCClassesUtf8;
|
||||
|
||||
|
||||
{ TAbBaseBrowser implementation ======================================= }
|
||||
|
||||
@@ -515,7 +519,7 @@
|
||||
|
||||
@@ -515,66 +519,84 @@
|
||||
function AbDetermineArcType(const FN : string; AssertType : TAbArchiveType) : TAbArchiveType;
|
||||
var
|
||||
Ext : string;
|
||||
|
|
@ -381,10 +381,9 @@ Index: AbBrowse.pas
|
|||
begin
|
||||
Result := AssertType;
|
||||
if Result = atUnknown then begin
|
||||
@@ -522,59 +526,77 @@
|
||||
{ Guess archive type based on it's extension }
|
||||
Ext := UpperCase(ExtractFileExt(FN));
|
||||
if (Ext = '.ZIP') or (Ext = '.JAR') then
|
||||
- if (Ext = '.ZIP') or (Ext = '.JAR') then
|
||||
- Result := atZip;
|
||||
- if (Ext = '.EXE') then
|
||||
- Result := atSelfExtZip;
|
||||
|
|
@ -400,6 +399,7 @@ Index: AbBrowse.pas
|
|||
- Result := atBzip2;
|
||||
- if (Ext = '.TBZ') then
|
||||
- Result := atBzippedTar;
|
||||
+ if (Ext = '.ZIP') or (Ext = '.JAR') or (Ext = '.ZIPX') then
|
||||
+ Result := atZip
|
||||
+ else if (Ext = '.EXE') then
|
||||
+ Result := atSelfExtZip
|
||||
|
|
@ -441,7 +441,7 @@ Index: AbBrowse.pas
|
|||
- case Result of
|
||||
- atZip : begin
|
||||
- Result := VerifyZip(FS);
|
||||
+ try
|
||||
+ try
|
||||
+ FS := TFileStreamEx.Create(FN, fmOpenRead or fmShareDenyNone);
|
||||
+ try
|
||||
+ if Result <> atUnknown then begin
|
||||
|
|
@ -2418,17 +2418,28 @@ Index: AbZipPrc.pas
|
|||
===================================================================
|
||||
--- AbZipPrc.pas (revision 512)
|
||||
+++ AbZipPrc.pas (working copy)
|
||||
@@ -67,7 +67,8 @@
|
||||
@@ -67,7 +67,9 @@
|
||||
AbVMStrm,
|
||||
AbDfBase,
|
||||
AbDfEnc,
|
||||
- AbSpanSt;
|
||||
+ AbSpanSt,
|
||||
+ AbXzPrc,
|
||||
+ DCClassesUtf8;
|
||||
|
||||
|
||||
|
||||
|
||||
{ ========================================================================== }
|
||||
@@ -294,22 +295,14 @@
|
||||
@@ -209,6 +211,9 @@
|
||||
try
|
||||
if InStream.Size > 0 then begin
|
||||
|
||||
+ if SameText(ExtractFileExt(Sender.ArchiveName), '.zipx') then
|
||||
+ DoCompressXz(ZipArchive, Item, DestStrm, InStream)
|
||||
+ else
|
||||
{ determine how to store Item based on specified CompressionMethodToUse }
|
||||
case ZipArchive.CompressionMethodToUse of
|
||||
smDeflated : begin
|
||||
@@ -294,22 +299,14 @@
|
||||
OutStream : TStream );
|
||||
var
|
||||
UncompressedStream : TStream;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue