[fpc-pascal] Get empty memory quickly or... an empty file
Reinier Olislagers
reinierolislagers at gmail.com
Fri Sep 13 13:16:45 CEST 2013
I'm working on implementing zip64 support and trying to test things by
compressing large files or streams using FPC's zip code.
Currently using this to get a huge memorystream filled with the same
data - so it should compress very well:
...
ContentStream:=TMemoryStream.Create();
ContentStream.SetSize(1+$FFFFFFFF); //4 bytes+1
ContentStream.Position:=0;
Buffer:='A'; //pchar
for i:=0 to ContentStream.Size-1 do
begin
ContentStream.Write(Buffer,1);
end;
ContentStream.Position:=0;
writeln('Buffer created');
try
Zipper.Entries.AddFileEntry(ContentStream, ArchiveFile);
writeln('entry added');
Zipper.ZipAllFiles;
finally
ContentStream.Free;
...
However, I'm sure there must be quicker ways (e.g. less newbie code;
using OS functions to quickly create empty memor, or alternatively
create a sparse file and zip the file instead of the stream).
Suggestions?
Thanks,
Reinier
More information about the fpc-pascal
mailing list