Click to See Complete Forum and Search --> : Windows disk caching issue


brivers
December 21st, 2004, 12:38 PM
Does anyone know if there is a way to tell whether or not a file has any pending writes? In my app there is an external program that creates a file which I need to read in my app. However, I seem to be trying to read the file before it's been completely written (due to Windows write-back disk caching). How can I synchronize my reads? In Linux/Unix I would use select() or poll(). Does Windows have anything similar?

Thanks!

NoHero
December 21st, 2004, 12:46 PM
I have another solution. Why not opening file and try to lock it. (just put the dwShare flag to 0) If the other application is still writing your CreateFile() function will fail. If the other application is done and closes the file, your CreateFile() will work and is ready for read. (That's how I would do that).

/ But I'll keep looking for other solutions, because mine has some bad issues though.