Jump to content
  • Advertisement
Sign in to follow this  
programmer_tom

File changes with ReadDirectoryChangesW()

This topic is 3778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all I'm listening for file changes with ReadDirectoryChangesW(), and all is well in the universe. The problem is, I get called back several times upon a single 'save' to a file. I can't figure how to differentiate between the alerts. All I care about is when the file is completed writing its changes. I tried to tell by fopen(), but that succeeds all the time, not just when the file is done writing. Any ideas? -programmer_tom

Share this post


Link to post
Share on other sites
Advertisement
Instead of using fopen, try using CreateFile with read and write exculsivity set.
This worked for me in a similar situation.
The solution isn't very neat and the "correct" way might be to enumerate all handles to the file and check if it's zero.
I don't know how to do that but there are some tools that can list all handles to a file so there must be a way.
Edit: I had a problem using this technique though.
Because one of the tools that was writing a file that I needed to´detect changes to and act upon did some stupid things like:
open(new), write, close, open(append), write, close, ....., open(append), write, close.
I don't know how to test for that sort of things (worse was that if I opened the file with exclusivity the program would crash because it couldn't open the file since it's been locked by my test :().

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!