Hi i've these functions to Store Streams in One File :
Delphi-Quellcode:
function AddData(ID:string; pBuf: Pointer; Count: Integer): Integer;
var
Buff : Pointer;
begin
// FFile is of Type : TFileStream
FFile.Seek(0, soFromEnd);//--> the Container *
if( Result > -1 )then
begin
GetMem(Buff, Count);
try
Move(pBuf^, Buff^, Count);
Result := FFile.Write(Buff^, Count);
finally
FreeMem(Buff, Count);
end;
end;
end;
{* and here how i add Streams *}
function InsertStream(ID: String;aStream: TStream): Integer;
var
pBuff : Pointer;
begin
// alloc Mem for pBuff
GetMem(pBuff, aStream.Size);
try
aStream.Position := 0;
aStream.Read(pBuff^, aStream.Size);
// now add data
Result := AddData(ID, pBuff, aStream.Size);
finally
FreeMem(pBuff, aStream.Size);
end;
end;
my question is :
how could i optimize the InsertStream Function so that it can work fast for file's size more than 1 GB cause i cannot load such a huge size in Memory.
many thanks in advance