|
Boost Users : |
Subject: Re: [Boost-users] logfile write/poll mechanism
From: Scott Gifford (sgifford_at_[hidden])
Date: 2008-12-07 23:04:11
"Thijs Koerselman" <thijskoerselman_at_[hidden]> writes:
> 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.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net