Forum > General
How do I flush a TFileStream to disk
zakiwi:
Hi there,
Please could anyone help me.
I have an application that performs very fast read and write operations to a TFileStream object. I have been able to prove that the data being written is not always on the disk. ie. It's on it's way to the disk, but the FileStream.WriteBuffer() method returns before the data is actually on the disk. This causes problems when my program tries to read that segment of data shortly after it was written, but before it is actually on the disk.
Your help would be greatly appreciated.
Cheers
Zakiwi
typo:
Well, you could try to read from the stream instead of reading from file.
zakiwi:
Sorry, I should have made myself clear.
I am only reading and writing to and from the stream.
theo:
For Windows:
http://stackoverflow.com/questions/787019/how-to-flush-a-tfilestream
bflm:
--- Quote from: zakiwi on June 02, 2010, 10:10:48 pm ---This causes problems when my program tries to read that segment of data shortly after it was written, but before it is actually on the disk.
--- End quote ---
IMO it should have nothing to do with flushing/actually writing the data to the disk. To me it sounds more like a bug - either in TFileStream implementation or in file I/O (*) of the OS you're using or in your program. It could be helpful to provide a minimal example demonstrating this behavior to decide where the problem roots from.
(*) AFAIK typical OS caches file I/O a lot but the caching is and must be invisible to the semantics of reading any part of the file *after* being written to at any other point. At least from the perspective of a single process/thread and a local disk volume.
Navigation
[0] Message Index
[#] Next page