unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
Ledt1: TLabeledEdit;
lEdt2: TLabeledEdit;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
Bevel1: TBevel;
SplitBtn: TButton;
GenBtn: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure SplitBtnClick(Sender: TObject);
procedure GenBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
Stream, Container: TFileStream;
Size:
Array of Int64;
FileCount: LongWord;
f: TStringList;
procedure TForm1.Button1Click(Sender: TObject);
begin
If OpenDialog1.Execute
then
begin
lEdt1.Text := f[f.Add(OpenDialog1.FileName)];
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
If OpenDialog1.Execute
then
begin
lEdt2.Text := f[f.Add(OpenDialog1.FileName)];
end;
end;
procedure TForm1.SplitBtnClick(Sender: TObject);
var
i: Integer;
begin
try
Container := TFileStream.Create('
C:\Container.dat', fmOpenRead
or fmShareDenyWrite);
for i := 0
to FileCount - 1
do
begin
Stream := TFileStream.Create('
C:\stream'+IntToStr(i+1)+'
.dat', fmCreate
or fmShareExclusive);
try
Stream.CopyFrom(Container, Size[i+1]);
finally
Stream.Free;
end;
end;
finally
Container.Free;
end;
end;
procedure TForm1.GenBtnClick(Sender: TObject);
var
i: Integer;
begin
try
Container := TFileStream.Create('
C:\Container.dat', fmCreate
or fmShareDenyWrite);
Container.Position := 0;
for i := 0
to FileCount - 1
do
begin
Stream := TFileStream.Create(f[i], fmOpenRead
or fmShareExclusive);
try
Size[i+1] := Stream.Size;
Container.CopyFrom(Stream, 0);
finally
Stream.Free;
end;
end;
finally
Container.Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FileCount := 2;
SetLength(Size, FileCount);
f := TStringList.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
f.Free;
end;
end.