Stream question...

Started by
3 comments, last by misterPhyrePhox 18 years, 7 months ago
I have a log file being updated by a third party program... I am trying to figure out how to have my app. recognize that the log file has been edited or data has been appended to that log file. Sort of like a listen() for a file change. I looked through all the stuff in my book on file I/O and cannot seem to come up with any ideas. I assume there is something in the windows API for this... Any ideas would be helpful, -- Warhorseii
Advertisement
Each file should have a timestamp indicating when they've last been modified. Check it. How to do that depends on what OS you're using.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
The .NET framework contains a FileSystemWatcher class which can be used for this.
Boost Filesystem last_write_time could come in handy.
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style
I looked a little bit through MSDN, and found out about FindFirstChangeNotification.
You can use the function to monitor changes in your directory, and then use ReadDirectoryChanges to determine whether or not the file modified was your log file.

This topic is closed to new replies.

Advertisement