Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cached write issues 1

Status
Not open for further replies.

brivers

Programmer
Jun 8, 2004
14
0
0
US
Does anyone know how to get around Windows' cached writes without turning off caching for the entire hard drive? In Linux I can use select() or poll() to wait until the file is ready for reading or writing. It looks like Windows has select() for sockets, but will it work for files? Or is there some other function I can use to wait on a file whose contents haven't been written to disk yet?
 
I'd be interested in know what the solution is.


James P. Cottingham
-----------------------------------------
[sup]To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.[/sup]
 
It's kind of dumb, but it seems to work. All I did was set up a loop that calls CreateFile with dwShareMode set to 0 (ie. do not share). If it returns INVALID_HANDLE_VALUE then you know that some other process is still writing it. Seems to work for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top