diff options
author | Max Kellermann <max@duempel.org> | 2014-08-11 22:53:48 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-11 22:53:48 +0200 |
commit | 8283f23651580c57e199f7547f2c0a0512e868be (patch) | |
tree | aad15e492e743d6261f302b73271413b9fc7784d /src/fs | |
parent | 7cc25f91ffe240720c0692b7c75b9f566882dff0 (diff) | |
download | mpd-8283f23651580c57e199f7547f2c0a0512e868be.tar.gz mpd-8283f23651580c57e199f7547f2c0a0512e868be.tar.xz mpd-8283f23651580c57e199f7547f2c0a0512e868be.zip |
fs/io/TextFile: add method Check()
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/io/TextFile.cxx | 8 | ||||
-rw-r--r-- | src/fs/io/TextFile.hxx | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/fs/io/TextFile.cxx b/src/fs/io/TextFile.cxx index 5b3bc4505..28d6dabcb 100644 --- a/src/fs/io/TextFile.cxx +++ b/src/fs/io/TextFile.cxx @@ -61,3 +61,11 @@ TextFile::ReadLine() return buffered_reader->ReadLine(); } + +bool +TextFile::Check(Error &error) const +{ + assert(buffered_reader != nullptr); + + return buffered_reader->Check(error); +} diff --git a/src/fs/io/TextFile.hxx b/src/fs/io/TextFile.hxx index 8bab808c7..5577363e7 100644 --- a/src/fs/io/TextFile.hxx +++ b/src/fs/io/TextFile.hxx @@ -56,10 +56,18 @@ public: * space. There is a reasonable maximum line length, only to * 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 * @return a pointer to the line, or nullptr on end-of-file or error */ char *ReadLine(); + + /** + * Check whether a ReadLine() call has thrown an error. + */ + bool Check(Error &error) const; }; #endif |