Commit 8283f236 authored by Max Kellermann's avatar Max Kellermann

fs/io/TextFile: add method Check()

parent 7cc25f91
...@@ -61,3 +61,11 @@ TextFile::ReadLine() ...@@ -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);
}
...@@ -56,10 +56,18 @@ public: ...@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment