An existing application writes an output file constantly as it runs. I want to be able to read this file in another (C++) application, line by line, for external processing.
A realistic scenario is the existing application has been running for some time. My new application is launched and works through the output file, 'catching up' to the most recent entry. It then waits for new lines to be written to the file.
I do not need to parse the entire file, only to read it line-by-line - it's not XML or JSON or anything like that. As the file may be very large, I definitely don't want to load it all into memory. It's been a very long time since I worked on low-level file access in C++ so my questions are:
- Do the standard file APIs allow me to read a file without caching it in-memory, if so how can I control this?
- Does it require special attention reading from a file which is being written to?
I know this can be done at operating-system level, but I'm not sure how this is exposed through the C++ APIs in the standard library.