ADD: Some fixes and optimizations for Zip plugin

This commit is contained in:
Alexander Koblov 2007-04-09 20:43:53 +00:00
commit 8a16ea3328
87 changed files with 224 additions and 269 deletions

View file

@ -10,16 +10,20 @@ del /Q doublecmd.compiled
del /Q plugins\cpio\bin\*.*
del /Q plugins\rpm\bin\*.*
del /Q plugins\zip\bin\*.*
del /Q plugins\unbz2\bin\*.*
del /Q plugins\cpio\*.bak
del /Q plugins\rpm\*.bak
del /Q plugins\zip\*.bak
del /Q plugins\unbz2\*.bak
del /Q plugins\zip\*.or
del /Q plugins\unbz2\*.or
del /Q plugins\cpio\*.*~
del /Q plugins\rpm\*.*~
del /Q plugins\zip\*.*~
del /Q plugins\unbz2\*.*~
del /Q components\KASToolBar\lib\i386-win32\*.*
del /Q components\viewer\lib\i386-win32\*.*

View file

@ -1,5 +0,0 @@
<?xml version="1.0"?>
<CONFIG>
<Compiler Value="X:\Prog\Lazarus\pp\bin\i386-win32\ppc386.exe" Date="877110550"/>
<Params Value=" -S2cdgi -CX -OG1 -gl -vewnhi -l -FuX:\linux\Delphi\ARC_FPC\fparchive-0.1\ -Fu. -oX:\linux\Delphi\ARC_FPC\zip.exe Zip.dpr"/>
</CONFIG>

View file

@ -1,94 +1,131 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="5"/>
<General>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=".wcx"/>
<ActiveEditorIndexAtStart Value="2"/>
</General>
<LazDoc Paths=""/>
<PublishOptions>
<Version Value="2"/>
<DestinationDirectory Value="$(TestDir)\publishedproject\"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="4">
<Unit0>
<Filename Value="Zip.dpr"/>
<IsPartOfProject Value="True"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="0"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="wcxhead.pas"/>
<UnitName Value="wcxhead"/>
<CursorPos X="21" Y="8"/>
<TopLine Value="1"/>
<EditorIndex Value="2"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
<Filename Value="ZipFunc.pas"/>
<UnitName Value="ZipFunc"/>
<CursorPos X="20" Y="6"/>
<TopLine Value="1"/>
<EditorIndex Value="1"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="fparchive-0.1\abfcifdi.pas"/>
<UnitName Value="AbFciFdi"/>
<CursorPos X="1" Y="420"/>
<TopLine Value="407"/>
<UsageCount Value="10"/>
</Unit3>
</Units>
<JumpHistory Count="0" HistoryIndex="-1"/>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<PathDelim Value="\"/>
<SearchPaths>
<OtherUnitFiles Value="fparchive-0.1\"/>
<UnitOutputDirectory Value="bin"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<DelphiCompat Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<Generate Value="Faster"/>
</CodeGeneration>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="2">
<Item1>
<Name Value="ECodetoolError"/>
</Item1>
<Item2>
<Name Value="EFOpenError"/>
</Item2>
</Exceptions>
</Debugging>
</CONFIG>
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="5"/>
<General>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=".wcx"/>
<ActiveEditorIndexAtStart Value="1"/>
</General>
<PublishOptions>
<Version Value="2"/>
<DestinationDirectory Value="$(TestDir)\publishedproject\"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="8">
<Unit0>
<Filename Value="Zip.dpr"/>
<IsPartOfProject Value="True"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="0"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="wcxhead.pas"/>
<UnitName Value="wcxhead"/>
<CursorPos X="21" Y="8"/>
<TopLine Value="1"/>
<UsageCount Value="10"/>
</Unit1>
<Unit2>
<Filename Value="ZipFunc.pas"/>
<UnitName Value="ZipFunc"/>
<CursorPos X="18" Y="6"/>
<TopLine Value="1"/>
<EditorIndex Value="1"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="fparchive-0.1\abfcifdi.pas"/>
<UnitName Value="AbFciFdi"/>
<CursorPos X="1" Y="420"/>
<TopLine Value="407"/>
<UsageCount Value="10"/>
</Unit3>
<Unit4>
<Filename Value="fparchive-0.1\abarctyp.pas"/>
<UnitName Value="AbArcTyp"/>
<CursorPos X="14" Y="118"/>
<TopLine Value="102"/>
<UsageCount Value="10"/>
</Unit4>
<Unit5>
<Filename Value="..\..\..\..\..\Prog\lazarus\fpcsrc\rtl\objpas\sysutils\finah.inc"/>
<CursorPos X="25" Y="30"/>
<TopLine Value="13"/>
<UsageCount Value="10"/>
</Unit5>
<Unit6>
<Filename Value="fparchive-0.1\abbrowse.pas"/>
<UnitName Value="AbBrowse"/>
<CursorPos X="36" Y="198"/>
<TopLine Value="182"/>
<UsageCount Value="10"/>
</Unit6>
<Unit7>
<Filename Value="fparchive-0.1\abutils.pas"/>
<UnitName Value="AbUtils"/>
<CursorPos X="3" Y="88"/>
<TopLine Value="72"/>
<UsageCount Value="10"/>
</Unit7>
</Units>
<JumpHistory Count="3" HistoryIndex="2">
<Position1>
<Filename Value="ZipFunc.pas"/>
<Caret Line="49" Column="29" TopLine="46"/>
</Position1>
<Position2>
<Filename Value="ZipFunc.pas"/>
<Caret Line="73" Column="21" TopLine="49"/>
</Position2>
<Position3>
<Filename Value="ZipFunc.pas"/>
<Caret Line="43" Column="54" TopLine="26"/>
</Position3>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<PathDelim Value="\"/>
<SearchPaths>
<OtherUnitFiles Value="fparchive\;..\..\"/>
<UnitOutputDirectory Value="bin"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<DelphiCompat Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<Generate Value="Faster"/>
</CodeGeneration>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="2">
<Item1>
<Name Value="ECodetoolError"/>
</Item1>
<Item2>
<Name Value="EFOpenError"/>
</Item2>
</Exceptions>
</Debugging>
</CONFIG>

View file

@ -1,14 +1,10 @@
{
File name: zipfunc.pas
Double commander
-------------------------------------------------------------------------
WCX plugin for working with *.zip, *.gz, *.tar, *.tgz archives
Author: Koblov Alexander (Alexx2000@mail.ru)
Plugin functions
Copyright (C) 2006
contributors:
Copyright (C) 2007 Koblov Alexander (Alexx2000@mail.ru)
This program is free software; you can redistribute it and/or
@ -31,7 +27,7 @@
unit ZipFunc;
interface
uses wcxhead;
uses uWCXhead;
{Mandatory functions}
function OpenArchive (var ArchiveData : tOpenArchiveData) : THandle;{$IFNDEF WIN32}cdecl{$ELSE}stdcall{$ENDIF};
@ -46,52 +42,90 @@ function GetPackerCaps : Integer;{$IFNDEF WIN32}cdecl{$ELSE}stdcall{$ENDIF};
implementation
uses AbZipKit, SysUtils, Classes;
uses AbZipKit, AbUtils, SysUtils, Classes;//, windows;
var
Arc : TAbZipKit;
function ExtractOnlyFileName(const FileName: string): string;
var
iDotIndex,
I: longint;
sExt : String;
begin
(* Find a dot index *)
I := Length(FileName);
while (I > 0) and not (FileName[I] in ['.', '/', '\', ':']) do Dec(I);
if (I > 0) and (FileName[I] = '.') then
begin
iDotIndex := I;
sExt := Copy(FileName, I, MaxInt);
end
else
begin
iDotIndex := MaxInt;
sExt := '';
end;
(* Find file name index *)
I := Length(FileName);
while (I > 0) and not (FileName[I] in ['/', '\', ':']) do Dec(I);
Result := Copy(FileName, I + 1, iDotIndex - I - 1);
if sExt = '.tgz' then
Result := Result + '.tar';
end;
function OpenArchive (var ArchiveData : tOpenArchiveData) : THandle;
begin
if not Assigned(Arc) Then
Arc := TAbZipKit.Create(nil);
//MessageBox(0,ArchiveData.ArcName,'OpenArchive',16);
Arc.OpenArchive(ArchiveData.ArcName);
Arc.Tag :=0;
//MessageBox(0,'OpenArchive','OpenArchive',16);
Result :=Cardinal(Arc);
if not Assigned(Arc) Then
Arc := TAbZipKit.Create(nil);
//MessageBox(0,ArchiveData.ArcName,'OpenArchive',16);
Arc.OpenArchive(ArchiveData.ArcName);
Arc.Tag :=0;
//MessageBox(0,'OpenArchive','OpenArchive',16);
Result :=Cardinal(Arc);
end;
function ReadHeader (hArcData : THandle; var HeaderData : THeaderData) : Integer;
var
I, Size : Integer;
Year, Month, Day,
Hour, Min, Sec, MSec: Word;
I, Size : Integer;
Year, Month, Day,
Hour, Min, Sec, MSec: Word;
sFileName : String;
begin
if Arc.Tag > Arc.Count - 1 then
begin
Result := E_END_ARCHIVE;
exit;
end;
if Arc.Tag > Arc.Count - 1 then
begin
Result := E_END_ARCHIVE;
exit;
end;
with HeaderData do
begin
//MessageBox(0,PChar(Arc.Items[Arc.Tag].FileName),'',16);
with HeaderData do
begin
//MessageBox(0,PChar(Arc.Items[Arc.Tag].FileName),'',16);
StrPCopy(FileName, Arc.Items[Arc.Tag].FileName);
PackSize := Arc.Items[Arc.Tag].CompressedSize;
UnpSize := Arc.Items[Arc.Tag].UncompressedSize;
FileCRC := Arc.Items[Arc.Tag].CRC32;
{File date/time}
DecodeDate(Arc.Items[Arc.Tag].LastModTimeAsDateTime, Year, Month, Day);
DecodeTime(Arc.Items[Arc.Tag].LastModTimeAsDateTime, Hour, Min, Sec, MSec);
FileTime := (Year - 1980) shl 25 or (Month shl 21) or (Day shl 16) or (Hour shl 11) or (Min shl 5) or (Sec div 2);
FileAttr := Arc.Items[Arc.Tag].ExternalFileAttributes;
sFileName := Arc.Items[Arc.Tag].FileName;
if (Arc.ArchiveType in [atGzip, atGzippedTar]) and (sFileName = 'unknown') then
sFileName := ExtractOnlyFileName(Arc.FileName);
DoDirSeparators(sFileName);
sFileName := ExcludeTrailingPathDelimiter(sFileName);
end;
Result := 0;
StrPCopy(FileName, sFileName);
PackSize := Arc.Items[Arc.Tag].CompressedSize;
UnpSize := Arc.Items[Arc.Tag].UncompressedSize;
FileCRC := Arc.Items[Arc.Tag].CRC32;
{File date/time}
DecodeDate(Arc.Items[Arc.Tag].LastModTimeAsDateTime, Year, Month, Day);
DecodeTime(Arc.Items[Arc.Tag].LastModTimeAsDateTime, Hour, Min, Sec, MSec);
FileTime := (Year - 1980) shl 25 or (Month shl 21) or (Day shl 16) or (Hour shl 11) or (Min shl 5) or (Sec div 2);
FileAttr := Arc.Items[Arc.Tag].ExternalFileAttributes;
end;
Result := 0;
end;
@ -124,9 +158,9 @@ end;
function CloseArchive (hArcData : THandle) : Integer;
begin
Arc.CloseArchive;
FreeAndNil(Arc);
Result := 0;
Arc.CloseArchive;
FreeAndNil(Arc);
Result := 0;
end;
procedure SetChangeVolProc (hArcData : THandle; pChangeVolProc1 : PChangeVolProc);
@ -141,22 +175,22 @@ end;
function DeleteFiles (PackedFile, DeleteList : PChar) : Integer;
begin
try
if not Assigned(Arc) Then
Arc := TAbZipKit.Create(nil);
Arc.OpenArchive(PackedFile);
Arc.DeleteFiles(DeleteList);
Arc.CloseArchive;
FreeAndNil(Arc);
Result := 0;
except
Result := E_BAD_DATA;
end;
try
if not Assigned(Arc) Then
Arc := TAbZipKit.Create(nil);
Arc.OpenArchive(PackedFile);
Arc.DeleteFiles(DeleteList);
Arc.CloseArchive;
FreeAndNil(Arc);
Result := 0;
except
Result := E_BAD_DATA;
end;
end;
function GetPackerCaps : Integer;
begin
Result := PK_CAPS_DELETE or PK_CAPS_MODIFY or PK_CAPS_MULTIPLE;
Result := PK_CAPS_DELETE or PK_CAPS_MODIFY or PK_CAPS_MULTIPLE;
end;

View file

@ -1,115 +0,0 @@
{ Contents of file wcxhead.pas }
{ It contains definitions of error codes, flags and callbacks }
unit wcxhead;
interface
uses SysUtils;
const {Error codes returned to calling application}
E_END_ARCHIVE= 10; {No more files in archive}
E_NO_MEMORY= 11; {Not enough memory}
E_BAD_DATA= 12; {Data is bad}
E_BAD_ARCHIVE= 13; {CRC error in archive data}
E_UNKNOWN_FORMAT= 14; {Archive format unknown}
E_EOPEN= 15; {Cannot open existing file}
E_ECREATE= 16; {Cannot create file}
E_ECLOSE= 17; {Error closing file}
E_EREAD= 18; {Error reading from file}
E_EWRITE= 19; {Error writing to file}
E_SMALL_BUF= 20; {Buffer too small}
E_EABORTED= 21; {Function aborted by user}
E_NO_FILES= 22; {No files found}
E_TOO_MANY_FILES= 23; {Too many files to pack}
E_NOT_SUPPORTED= 24; {Function not supported}
{Unpacking flags}
PK_OM_LIST= 0;
PK_OM_EXTRACT= 1;
{Flags for ProcessFile}
PK_SKIP= 0; {Skip file (no unpacking)}
PK_TEST= 1; {Test file integrity}
PK_EXTRACT= 2; {Extract file to disk}
{Flags passed through ChangeVolProc}
PK_VOL_ASK= 0; {Ask user for location of next volume}
PK_VOL_NOTIFY= 1; {Notify app that next volume will be unpacked}
{Packing flags}
{For PackFiles}
PK_PACK_MOVE_FILES= 1; {Delete original after packing}
PK_PACK_SAVE_PATHS= 2; {Save path names of files}
{Returned by GetPackCaps}
PK_CAPS_NEW= 1; {Can create new archives}
PK_CAPS_MODIFY= 2; {Can modify exisiting archives}
PK_CAPS_MULTIPLE= 4; {Archive can contain multiple files}
PK_CAPS_DELETE= 8; {Can delete files}
PK_CAPS_OPTIONS= 16; {Supports the options dialogbox}
PK_CAPS_MEMPACK= 32; {Supports packing in memory}
PK_CAPS_BY_CONTENT= 64; {Detect archive type by content}
PK_CAPS_SEARCHTEXT= 128; {Allow searching for text in archives
{ created with this plugin}
PK_CAPS_HIDE= 256; { Show as normal files (hide packer icon) }
{ open with Ctrl+PgDn, not Enter }
{Flags for packing in memory}
MEM_OPTIONS_WANTHEADERS=1; {Return archive headers with packed data}
{Errors returned by PackToMem}
MEMPACK_OK= 0; {Function call finished OK, but there is more data}
MEMPACK_DONE= 1; {Function call finished OK, there is no more data}
type
{Definition of callback functions called by the DLL}
{Ask to swap disk for multi-volume archive}
PChangeVolProc=^TChangeVolProc;
TChangeVolProc=function(ArcName:pchar;Mode:longint):longint; stdcall;
{Notify that data is processed - used for progress dialog}
PProcessDataProc=^TProcessDataProc;
TProcessDataProc=function(FileName:pchar;Size:longint):longint; stdcall;
type
THeaderData=packed record
ArcName:array [0..259] of char;
FileName:array [0..259] of char;
Flags,
PackSize,
UnpSize,
HostOS,
FileCRC,
FileTime,
UnpVer,
Method,
FileAttr:longint;
CmtBuf:pchar;
CmtBufSize,
CmtSize,
CmtState:longint;
end;
tOpenArchiveData=packed record
ArcName:pchar;
OpenMode,
OpenResult:longint;
CmtBuf:pchar;
CmtBufSize,
CmtSize,
CmtState:longint;
end;
tPackDefaultParamStruct=record
size,
PluginInterfaceVersionLow,
PluginInterfaceVersionHi:longint;
DefaultIniName:array[0..MAX_PATH-1] of char;
end;
pPackDefaultParamStruct=^tPackDefaultParamStruct;
implementation
end.