合并:
procedure CombineStream(SrcName: string; Src, Dst: TStream);
var
l: Integer;
begin
l := length(srcname);
with dst do
begin
writebuffer(l, sizeof(integer));
writebuffer(srcname[1], l);
l := src.size;
writebuffer(l, sizeof(integer));
copyfrom(src);
end;
end;
读取:
procedure ReadAnyStream(Dst, Src: TStream; Name: string);
var
l: Integer;
buffer: string;
begin
with src do
begin
seek(0,0);
repeat
readbuffer(l, sizeof(integer));
setlength(buffer, l);
readbuffer(buffer[1], l);
readbuffer(l, sizeof(integer));
if buffer=name then
begin
dst.copyfrom(src, l);
break;
end
else seek(1, l);
until position >= size;
end;
end;