
Hi, This might not be a Boost question. I'm not sure. I have 2 independent applications. One is writing information to a log file somewhere, the other contains a console window. What I would like to do is poll the log file from the application with the console window, and write any new lines (since last poll) to the window. It's seems like a fairly trivial thing to implement, but I don't have a lot of experience dealing with files, and I suspect there are already facilities to do such a thing. Can someone please point me in the right direction? Cheers, Thijs

"Thijs Koerselman"
Hi,
This might not be a Boost question. I'm not sure.
I have 2 independent applications. One is writing information to a log file somewhere, the other contains a console window. What I would like to do is poll the log file from the application with the console window, and write any new lines (since last poll) to the window.
The general technique is to read to the end of the file, then periodically check the file's size to see if it's grown; if so, keep reading (possibly doing an explicit seek to the point you were at when you last saw EOF, to reset any internal flags) until you get EOF again. This is basically what the Unix command "tail -f" does. If you're on Unix you may want to use it; if you're not you may want to look at the source for ideas. Good luck! ----Scott.

On Mon, Dec 8, 2008 at 5:04 AM, Scott Gifford
The general technique is to read to the end of the file, then periodically check the file's size to see if it's grown; if so, keep reading (possibly doing an explicit seek to the point you were at when you last saw EOF, to reset any internal flags) until you get EOF again.
This is basically what the Unix command "tail -f" does. If you're on Unix you may want to use it; if you're not you may want to look at the source for ideas.
Thanks Scott. I'm on Unix atm, but it has to be crossplatform eventually. I'll look into the tail source. Thijs
participants (2)
-
Scott Gifford
-
Thijs Koerselman