[fpc-pascal] Get empty memory quickly or... an empty file

Reinier Olislagers reinierolislagers at gmail.com
Sun Sep 15 16:30:10 CEST 2013


On 13/09/2013 16:17, Michael Van Canneyt wrote:
> On Fri, 13 Sep 2013, Reinier Olislagers wrote:
>> On 13/09/2013 15:38, Marco van de Voort wrote:
>>> In our previous episode, Reinier Olislagers said:
>>>> 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).
>>>
>>> Do not create the data, but generate it in an overriden tstream
>>> read() call?
>>>
>>> If you can define a function that can generate "count" bytes of data at
>>> position n (in this case the function is constant), then you don't
>>> have to
>>> write it out.
>>>
>>> Ken in mind that TStream is an abstraction, not necessarily a block of
>>> (RAM or disk) memory.
>>
>> Mmm, yes, that sounds very smart, thanks!
> 
> Attached a NullStream implementation.
> 

Thanks a lot; I extended it a bit so it looks a bit more like a
TMemoryStream and use it in the tests for zipping. Works nicely.

Oh, in case somebody wants to have a look, I've uploaded a patch for
zip64 support ;)
http://bugs.freepascal.org/view.php?id=23533

Thanks to everybody here and on the forum for the help.



More information about the fpc-pascal mailing list