fs/io/TextFile: add method Check()

This commit is contained in:
Max Kellermann 2014-08-11 22:53:48 +02:00
parent 7cc25f91ff
commit 8283f23651
2 changed files with 16 additions and 0 deletions

View File

@ -61,3 +61,11 @@ TextFile::ReadLine()
return buffered_reader->ReadLine(); return buffered_reader->ReadLine();
} }
bool
TextFile::Check(Error &error) const
{
assert(buffered_reader != nullptr);
return buffered_reader->Check(error);
}

View File

@ -56,10 +56,18 @@ public:
* space. There is a reasonable maximum line length, only to * space. There is a reasonable maximum line length, only to
* prevent denial of service. * prevent denial of service.
* *
* Use Check() after nullptr has been returned to check
* whether an error occurred or end-of-file has been reached.
*
* @param file the source file, opened in text mode * @param file the source file, opened in text mode
* @return a pointer to the line, or nullptr on end-of-file or error * @return a pointer to the line, or nullptr on end-of-file or error
*/ */
char *ReadLine(); char *ReadLine();
/**
* Check whether a ReadLine() call has thrown an error.
*/
bool Check(Error &error) const;
}; };
#endif #endif