mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 01:09:25 +02:00
* Sample programs for TZipper and TUnzipper
git-svn-id: trunk@32862 -
This commit is contained in:
parent
df6efb6fc9
commit
4099abb0c1
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -6482,6 +6482,10 @@ packages/paszlib/examples/Makefile.fpc svneol=native#text/plain
|
|||||||
packages/paszlib/examples/example.pas svneol=native#text/plain
|
packages/paszlib/examples/example.pas svneol=native#text/plain
|
||||||
packages/paszlib/examples/example2.pas svneol=native#text/plain
|
packages/paszlib/examples/example2.pas svneol=native#text/plain
|
||||||
packages/paszlib/examples/extractodt.pas svneol=native#text/plain
|
packages/paszlib/examples/extractodt.pas svneol=native#text/plain
|
||||||
|
packages/paszlib/examples/fpunzipper.lpi svneol=native#text/plain
|
||||||
|
packages/paszlib/examples/fpunzipper.lpr svneol=native#text/plain
|
||||||
|
packages/paszlib/examples/fpzipper.lpi svneol=native#text/plain
|
||||||
|
packages/paszlib/examples/fpzipper.lpr svneol=native#text/plain
|
||||||
packages/paszlib/examples/minigzip.pas svneol=native#text/plain
|
packages/paszlib/examples/minigzip.pas svneol=native#text/plain
|
||||||
packages/paszlib/examples/miniunz.pas svneol=native#text/plain
|
packages/paszlib/examples/miniunz.pas svneol=native#text/plain
|
||||||
packages/paszlib/examples/minizip.pas svneol=native#text/plain
|
packages/paszlib/examples/minizip.pas svneol=native#text/plain
|
||||||
|
60
packages/paszlib/examples/fpunzipper.lpi
Normal file
60
packages/paszlib/examples/fpunzipper.lpi
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<CONFIG>
|
||||||
|
<ProjectOptions>
|
||||||
|
<Version Value="9"/>
|
||||||
|
<General>
|
||||||
|
<Flags>
|
||||||
|
<MainUnitHasCreateFormStatements Value="False"/>
|
||||||
|
<MainUnitHasTitleStatement Value="False"/>
|
||||||
|
<UseDefaultCompilerOptions Value="True"/>
|
||||||
|
</Flags>
|
||||||
|
<SessionStorage Value="InProjectDir"/>
|
||||||
|
<MainUnit Value="0"/>
|
||||||
|
<Title Value="fpunzipper"/>
|
||||||
|
<UseAppBundle Value="False"/>
|
||||||
|
<ResourceType Value="res"/>
|
||||||
|
</General>
|
||||||
|
<i18n>
|
||||||
|
<EnableI18N LFM="False"/>
|
||||||
|
</i18n>
|
||||||
|
<VersionInfo>
|
||||||
|
<StringTable ProductVersion=""/>
|
||||||
|
</VersionInfo>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="Default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
|
<PublishOptions>
|
||||||
|
<Version Value="2"/>
|
||||||
|
</PublishOptions>
|
||||||
|
<RunParams>
|
||||||
|
<local>
|
||||||
|
<FormatVersion Value="1"/>
|
||||||
|
</local>
|
||||||
|
</RunParams>
|
||||||
|
<Units Count="1">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="fpunzipper.lpr"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="fpzipper"/>
|
||||||
|
</Unit0>
|
||||||
|
</Units>
|
||||||
|
</ProjectOptions>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<Parsing>
|
||||||
|
<SyntaxOptions>
|
||||||
|
<UseAnsiStrings Value="False"/>
|
||||||
|
</SyntaxOptions>
|
||||||
|
</Parsing>
|
||||||
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<Exceptions Count="2">
|
||||||
|
<Item1>
|
||||||
|
<Name Value="ECodetoolError"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<Name Value="EFOpenError"/>
|
||||||
|
</Item2>
|
||||||
|
</Exceptions>
|
||||||
|
</Debugging>
|
||||||
|
</CONFIG>
|
80
packages/paszlib/examples/fpunzipper.lpr
Normal file
80
packages/paszlib/examples/fpunzipper.lpr
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
program fpzipper;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
uses
|
||||||
|
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||||
|
cthreads,
|
||||||
|
{$ENDIF}{$ENDIF}
|
||||||
|
Classes, SysUtils, CustApp, zipper
|
||||||
|
{ you can add units after this };
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TFPUnZipApplication }
|
||||||
|
|
||||||
|
TFPUnZipApplication = class(TCustomApplication)
|
||||||
|
Private
|
||||||
|
FUnZipper: TUnZipper;
|
||||||
|
FFiles : TStrings;
|
||||||
|
protected
|
||||||
|
procedure DoRun; override;
|
||||||
|
public
|
||||||
|
constructor Create(TheOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure WriteHelp; virtual;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TFPUnZipApplication }
|
||||||
|
|
||||||
|
procedure TFPUnZipApplication.DoRun;
|
||||||
|
|
||||||
|
Var
|
||||||
|
I : Integer;
|
||||||
|
F : TFileStream;
|
||||||
|
|
||||||
|
begin
|
||||||
|
If ParamCount<=1 then
|
||||||
|
begin
|
||||||
|
Writeln('Usage ',ParamStr(0),' zipfile file1 [file2 [...]]');
|
||||||
|
Terminate;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
FUnZipper.FileName:=ParamStr(1);
|
||||||
|
FUnZipper.Examine;
|
||||||
|
For I:=2 to ParamCount do
|
||||||
|
FFiles.Add(ParamStr(I));
|
||||||
|
FUnZipper.UnZipFiles(FFiles);
|
||||||
|
Terminate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TFPUnZipApplication.Create(TheOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(TheOwner);
|
||||||
|
StopOnException:=True;
|
||||||
|
FUnZipper:=TUnZipper.Create;
|
||||||
|
FFiles:=TStringList.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TFPUnZipApplication.Destroy;
|
||||||
|
begin
|
||||||
|
FreeAndNil(FFiles);
|
||||||
|
FreeAndNil(FUNZipper);
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPUnZipApplication.WriteHelp;
|
||||||
|
begin
|
||||||
|
{ add your help code here }
|
||||||
|
writeln('Usage: ',ExeName,' -h');
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
Application: TFPUnZipApplication;
|
||||||
|
begin
|
||||||
|
Application:=TFPUnZipApplication.Create(nil);
|
||||||
|
Application.Title:='UnZip application';
|
||||||
|
Application.Run;
|
||||||
|
Application.Free;
|
||||||
|
end.
|
||||||
|
|
100
packages/paszlib/examples/fpzipper.lpi
Normal file
100
packages/paszlib/examples/fpzipper.lpi
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<CONFIG>
|
||||||
|
<ProjectOptions>
|
||||||
|
<Version Value="9"/>
|
||||||
|
<General>
|
||||||
|
<Flags>
|
||||||
|
<LRSInOutputDirectory Value="False"/>
|
||||||
|
</Flags>
|
||||||
|
<MainUnit Value="0"/>
|
||||||
|
</General>
|
||||||
|
<VersionInfo>
|
||||||
|
<Language Value=""/>
|
||||||
|
<CharSet Value=""/>
|
||||||
|
<StringTable ProductVersion=""/>
|
||||||
|
</VersionInfo>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
|
<PublishOptions>
|
||||||
|
<Version Value="2"/>
|
||||||
|
<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="3">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="fpzipper.lpr"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<IsVisibleTab Value="True"/>
|
||||||
|
<TopLine Value="48"/>
|
||||||
|
<CursorPos X="4" Y="53"/>
|
||||||
|
<UsageCount Value="21"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
<LoadedDesigner Value="True"/>
|
||||||
|
</Unit0>
|
||||||
|
<Unit1>
|
||||||
|
<Filename Value="../src/zipper.pp"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<EditorIndex Value="-1"/>
|
||||||
|
<TopLine Value="2271"/>
|
||||||
|
<CursorPos X="32" Y="2286"/>
|
||||||
|
<UsageCount Value="21"/>
|
||||||
|
</Unit1>
|
||||||
|
<Unit2>
|
||||||
|
<Filename Value="zipper.pp"/>
|
||||||
|
<EditorIndex Value="1"/>
|
||||||
|
<TopLine Value="2380"/>
|
||||||
|
<CursorPos X="7" Y="2389"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit2>
|
||||||
|
</Units>
|
||||||
|
<JumpHistory Count="5" HistoryIndex="4">
|
||||||
|
<Position1>
|
||||||
|
<Filename Value="fpzipper.lpr"/>
|
||||||
|
<Caret Line="10" Column="6" TopLine="4"/>
|
||||||
|
</Position1>
|
||||||
|
<Position2>
|
||||||
|
<Filename Value="fpzipper.lpr"/>
|
||||||
|
<Caret Line="10" Column="6" TopLine="4"/>
|
||||||
|
</Position2>
|
||||||
|
<Position3>
|
||||||
|
<Filename Value="zipper.pp"/>
|
||||||
|
<Caret TopLine="43"/>
|
||||||
|
</Position3>
|
||||||
|
<Position4>
|
||||||
|
<Filename Value="zipper.pp"/>
|
||||||
|
<Caret Line="2395" Column="28" TopLine="2379"/>
|
||||||
|
</Position4>
|
||||||
|
<Position5>
|
||||||
|
<Filename Value="zipper.pp"/>
|
||||||
|
<Caret Line="571" TopLine="555"/>
|
||||||
|
</Position5>
|
||||||
|
</JumpHistory>
|
||||||
|
</ProjectOptions>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<Parsing>
|
||||||
|
<SyntaxOptions>
|
||||||
|
<UseAnsiStrings Value="False"/>
|
||||||
|
</SyntaxOptions>
|
||||||
|
</Parsing>
|
||||||
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<Exceptions Count="2">
|
||||||
|
<Item1>
|
||||||
|
<Name Value="ECodetoolError"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<Name Value="EFOpenError"/>
|
||||||
|
</Item2>
|
||||||
|
</Exceptions>
|
||||||
|
</Debugging>
|
||||||
|
</CONFIG>
|
80
packages/paszlib/examples/fpzipper.lpr
Normal file
80
packages/paszlib/examples/fpzipper.lpr
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
program fpzipper;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
uses
|
||||||
|
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||||
|
cthreads,
|
||||||
|
{$ENDIF}{$ENDIF}
|
||||||
|
Classes, SysUtils, CustApp, zipper
|
||||||
|
{ you can add units after this };
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TFPZipApplication }
|
||||||
|
|
||||||
|
TFPZipApplication = class(TCustomApplication)
|
||||||
|
Private
|
||||||
|
FZipper: TZipper;
|
||||||
|
protected
|
||||||
|
procedure DoRun; override;
|
||||||
|
public
|
||||||
|
constructor Create(TheOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure WriteHelp; virtual;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TFPZipApplication }
|
||||||
|
|
||||||
|
procedure TFPZipApplication.DoRun;
|
||||||
|
|
||||||
|
Var
|
||||||
|
I : Integer;
|
||||||
|
F : TFileStream;
|
||||||
|
begin
|
||||||
|
If ParamCount<=1 then
|
||||||
|
begin
|
||||||
|
Writeln('Usage ',ParamStr(0),' zipfile file1 [file2 [...]]');
|
||||||
|
Terminate;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
FZipper.FileName:=ParamStr(1);
|
||||||
|
For I:=2 to ParamCount do
|
||||||
|
begin
|
||||||
|
F:=TFileStream.Create(ParamStr(i),fmOpenRead);
|
||||||
|
FZipper.Entries.AddFileEntry(F,ParamStr(i));
|
||||||
|
end;
|
||||||
|
FZipper.ZipAllFiles;
|
||||||
|
For I:=0 to FZipper.Entries.Count-1 do
|
||||||
|
FZipper.Entries[I].Stream.Free;
|
||||||
|
Terminate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TFPZipApplication.Create(TheOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(TheOwner);
|
||||||
|
StopOnException:=True;
|
||||||
|
FZipper:=TZipper.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TFPZipApplication.Destroy;
|
||||||
|
begin
|
||||||
|
FreeAndNil(FZipper);
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPZipApplication.WriteHelp;
|
||||||
|
begin
|
||||||
|
{ add your help code here }
|
||||||
|
writeln('Usage: ',ExeName,' -h');
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
Application: TFPZipApplication;
|
||||||
|
begin
|
||||||
|
Application:=TFPZipApplication.Create(nil);
|
||||||
|
Application.Title:='Zip application';
|
||||||
|
Application.Run;
|
||||||
|
Application.Free;
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user