Hi,
Is there already a buffered file stream in the fpc sources? Or maybe a generic buffered input stream that can be used with TFileStream?
Mattias

Mailing lists / fpc-pascal / 2012-06
13 messages · 5 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi,
Is there already a buffered file stream in the fpc sources? Or maybe a generic buffered input stream that can be used with TFileStream?
Mattias
On Sun, Jun 10, 2012 at 4:00 PM, Mattias Gaertner <
check mine,
http://minilib.svn.sourceforge.net/viewvc/minilib/trunk/lib/mnStreams.pas?view=markup
Best Regards
Zaher Dirkey
Thanks, that seems to be a nice sequential text file reader/writer.
That's not what I search. I will try to be more specific:
I want to pass the stream to a binary reader, which skips big parts of the stream. It can seek backwards and the files can be several GB, so I need the int64 read/write/seek.
Maybe the word "buffer" is wrong, maybe "cache" is better.
Preferably the buffer size can be set
Is there already a buffered file stream in the fpc sources? Or maybe a generic buffered…
Mattias Gaertner wroteHi, Is there already a buffered file stream in the fpc sources?
Yes.
Or maybe a generic buffered input stream that can be used with TFileStream?
See fcl-base/src/bufstream.pp.
It is even documented on
http://www.freepascal.org/docs-html/fcl/bufstream/index.html
Amazing, don't you think ? ;-)
Michael.
On Sun, 10 Jun 2012 17:13:28 +0300 Thanks, that seems to be a nice sequential text file…
10.06.2012 18:40, Mattias Gaertner пишет:
I want to pass the stream to a binary reader, which skips big parts of the stream. It can seek backwards and the files can be several GB, so I need the int64 read/write/seek.
Do you mean buffered random access (smth like disk access in DBMS)?
yes
(smth like disk access in DBMS)?
Well, not as sophisticated as an DBMS. Just a cache, that accelerates small sequential reads.
Mattias
Yes. See fcl-base/src/bufstream.pp. It is even documented on…
:)
I guessed so.
> Or maybe a generic buffered input stream that can be used with > TFileStream? See fcl-base/src/bufstream.pp.
Ah, abbreviations. BufStream.
The fpc sources are always amazing.
Mattias
Maybe I miss something:
TReadBufStream.Seek calls FakeSeekForward, which calls Discard, which reads everything up to the position.
This is the right solution for pipes and small files, but for big files I need a real Seek.
Can TReadBufStream be extended with a property or should I create a new class?
Mattias
On Sun, 10 Jun 2012 19:08:40 +0400 yes Well, not as sophisticated as an DBMS. Just a…
10.06.2012 20:20, Mattias Gaertner пишет:
Only because yours is readonly. I dont know your real task, but I`m afraid you will have to implement this cache from scratch.
On Sun, 10 Jun 2012 16:54:30 +0200 (CEST) :) I guessed so. Ah, abbreviations. BufStream.…
As in: Bugs creep up at the most unexpected places... :)
Michael.
On Sun, 10 Jun 2012 18:24:14 +0200 Maybe I miss something: TReadBufStream.Seek calls…
Feel free to extend the existing classes. The classes are by no means set in stone...
They did the job for me, but use cases vary...
Michael.
Is there already a buffered file stream in the fpc sources? Or maybe a generic buffered…
MSEgui has a bufstream too: tcustombufstream in
lib/common/kernel/msestream.pas, I don't know if it fits your needs.
Martin
Looks promising. :)
Mattias