114 lines
2.8 KiB
Plaintext
114 lines
2.8 KiB
Plaintext
unit Main;
|
|
|
|
{ reSource Demo 2
|
|
Demonstrates the use of reSource to compress/decompress one file
|
|
at a time.
|
|
This behaviour is more similar to like what MS does in some of
|
|
their installation disks, where each individual file is compressed.
|
|
|
|
The main procedures are:
|
|
CompressToArchive
|
|
DecompressFromArchive
|
|
|
|
}
|
|
|
|
|
|
(**) interface (**)
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|
StdCtrls,
|
|
// engine - include the following units in your app to access TCentralFileHeader etc.
|
|
// your search path must contain the dir the units are located in.
|
|
ResourceCompUnit,
|
|
ArchiveHeadersUnit, ErrorUnit, EDosUnit, ArchiveManagerUnit, StructsUnit,
|
|
ExtCtrls, FileCtrl;
|
|
|
|
type
|
|
TMainForm = class(TForm)
|
|
Label1: TLabel;
|
|
Label2: TLabel;
|
|
CompressBtn: TButton;
|
|
DecompressBtn: TButton;
|
|
Label3: TLabel;
|
|
Label4: TLabel;
|
|
SourceFileEdit: TEdit;
|
|
ArchiveFileEdit: TEdit;
|
|
Label5: TLabel;
|
|
BrowseSourceBtn: TButton;
|
|
BrowseArchiveBtn: TButton;
|
|
SaveDialog1: TSaveDialog;
|
|
OpenDialog1: TOpenDialog;
|
|
Resource1: TResource;
|
|
Bevel1: TBevel;
|
|
DecompressArchiveEdit: TEdit;
|
|
Label6: TLabel;
|
|
BrowseBtn2: TButton;
|
|
ExtractFileNameEdit: TEdit;
|
|
Label7: TLabel;
|
|
Label8: TLabel;
|
|
DirListBox: TDirectoryListBox;
|
|
Label9: TLabel;
|
|
Label10: TLabel;
|
|
procedure BrowseSourceBtnClick(Sender: TObject);
|
|
procedure BrowseArchiveBtnClick(Sender: TObject);
|
|
procedure CompressBtnClick(Sender: TObject);
|
|
procedure DecompressBtnClick(Sender: TObject);
|
|
procedure BrowseBtn2Click(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
MainForm: TMainForm;
|
|
|
|
(**) implementation (**)
|
|
|
|
{$R *.DFM}
|
|
|
|
procedure TMainForm.BrowseSourceBtnClick(Sender: TObject);
|
|
var
|
|
s: string;
|
|
begin
|
|
if OpenDialog1.Execute then
|
|
begin
|
|
s := OpenDialog1.FileName;
|
|
SourceFileEdit.Text := s;
|
|
// suggest a name for the archive file
|
|
if ArchiveFileEdit.Text = '' then
|
|
ArchiveFileEdit.Text := ChangeFileExt(s, '.rs');
|
|
end;
|
|
end;
|
|
|
|
procedure TMainForm.BrowseArchiveBtnClick(Sender: TObject);
|
|
begin
|
|
if SaveDialog1.Execute then
|
|
begin
|
|
ArchiveFileEdit.Text := SaveDialog1.FileName;
|
|
end;
|
|
end;
|
|
|
|
procedure TMainForm.CompressBtnClick(Sender: TObject);
|
|
begin
|
|
reSource1.CompressToArchive(SourceFileEdit.Text, ArchiveFileEdit.Text);
|
|
end;
|
|
|
|
procedure TMainForm.DecompressBtnClick(Sender: TObject);
|
|
begin
|
|
reSource1.DecompressFromArchive(DecompressArchiveEdit.Text, DirListBox.Directory,
|
|
ExtractFileNameEdit.Text);
|
|
end;
|
|
|
|
procedure TMainForm.BrowseBtn2Click(Sender: TObject);
|
|
begin
|
|
{Archive for decompression}
|
|
if SaveDialog1.Execute then
|
|
begin
|
|
DecompressArchiveEdit.Text := SaveDialog1.FileName;
|
|
end;
|
|
end;
|
|
|
|
end.
|