[fpc-devel] TBufferedFileStream
José Mejuto
joshyfun at gmail.com
Sun Sep 4 01:20:58 CEST 2016
El 04/09/2016 a las 0:23, silvioprog escribió:
> ----------------------------------------------
> CACHE 1000000 byte sequential reads in 46 ms.
> FILE 1000000 byte sequential reads in 2200 ms.
> ----------------------------------------------
>
> [...]
>
> Did you get this result from some sample? If so, could you share it?! I
> would be glad to test it checking the TBufferedFileStream performance. :-)
>
Hello,
Yes, the code is in the test for TBufferedFileStream in the bug ticket
http://bugs.freepascal.org/view.php?id=30549
Delphi TBufferedFileStream should be faster as I think it implementes a
dumb buffer, or just better a read ahead buffer, so it works better for
sequential read and worst for butterfly reads on same zones.
For my works I just use my class TCacheStream which applies the same
cache code but over any stream already created. I need this as a stream
filter because I'm working on virtual file systems which access a stream
(whichever class) as a blocks device stream, so I can in example work
with ZIP files as they was a disk with functions to browse the ZIP
entries, create files, delete, read and write, once each "file" is
closed and the stream that holds the whole file is freed in destroy it
updates the zip according, compressing new and modified streams and
copying/moving the blocks not touched.
Part of this code is in the Excel reader/writer in fpspreadsheet package.
Most of this classes are mostly beta versions, operative in my
environment but not valid for wide use, that's the reason I had not
published them (and the lack of comments, and code convolution).
Currently I have, more or less:
Native filesystem: Read/Write. Maps the native filesystem to my virtual
filesystem.
ZIP filesystem: Read/Write. Up to 2GB zip files.
FAT16: Read. Typical dd images.
FAT32: Read. Typical dd images.
Microsoft Binary Compound: Read/Write with limitations. Used in XLS, DOC,...
Sample filesystem: Read/Write. Very limited sample filesystem.
MBR Partition: Read. Used to access dd images when partition information
is available.
RAR: Browse only. With special crafted dll for windows also decompress,
but it is a dirty hack.
ISO: Read only. Limited and based in GPL code.
The virtual file system allows to mount an filesystem (above) in a
folder for browsing, open, and so on, so in example you open a ZIP and
inside you find another zip, you can mount the inner stream in a folder
and access to inner files transparently to your code, with a path like
F:=VirtualLayerRoot.CreateStream("/zip1/zip2/myfile.txt",fmOpenRead);
I can publish the code but I can not provide any guarantee of correct
work and that it will not delete all your hard disk :)
--
More information about the fpc-devel
mailing list