Michael Van Canneyt
michael at freepascal.org
Sun Sep 4 14:04:53 CEST 2016
On Sun, 4 Sep 2016, José Mejuto wrote:
> El 04/09/2016 a las 7:15, Michael Van Canneyt escribió:
>>> In the other hand a cache system is powerful than a buffered system if
>>> you are writing something like a filesystem over a TFileStream where
>>> you may need to jump here and there to read data, file allocation
>>> tables, attributes, and so on, in this case a cache with multiple
>>> pages instead just one improves the result (avoid multiple reads in
>>> the same zones).
>> And why did you not use the bufstream unit of FPC ?
>> The TBufStream stream implemented there works with any other stream, not
>> just files.
> In fact I wrote my code over TStream but in Delphi the class is inherited
> from TFileStream so I take my "TStreamFilter" and adapt it to inherit from
> TFileStream just as Delphi do.
> The second powerful reason is that I was not aware about TBufStream :)
It's even documented.
> TBufStream does support seek ? And SetSize ?
Seek: yes. Setsize not.
The TBufStream class has 2 descendents: one for reading, one for writing.
This means the implementation is much more simple, and for most usecases,
this is sufficient.
> My code like TBufStream inherits from TStream. Which is the advantage of
> inherit from TOwnerStream ?
TOwnerStream is only useful if you have a second stream which you use as a
source. It will free it for you. This is useful when chaining streams.
I will add your implementation to the bufstream unit.
It offers more functionality, but works only on files.
It's - as usual - a tradeoff.
More information about the fpc-devel